git-svn-id: https://msi/svn/firstRepo/Management/trunk@57 0f545695-f87b-41b6-9a03-7f16563b5454

This commit is contained in:
2016-01-29 16:51:39 +00:00
parent e5ee39281d
commit d45146fc23
3 changed files with 66 additions and 49 deletions
+59 -47
View File
@@ -84,6 +84,48 @@ define(['jquery', 'underscore', 'backbone', 'text!modules/editricetta/editricett
return true;
return false;
},
save:function(callback)
{
if (this.validate()) {
var diffi = $('#lvlDiff').val();
var ingr = $('#listbox').jqxListBox('source');
var sendobj = {
"ricettaID": $("#ricettaID").val(),
"categoria_id": $("#categoria").val(),
"titolo": escape($("#titolo").val()),
"ingredienti": [],
"preparazione": $("#procedimento").val(),
"autore": escape($("#autore").val()),
"linkFonte": $("#linkFonte").val(),
"linkVideo": $("#linkYouTube").val(),
"difficolta": diffi
};
$.each(ingr, function(i, val) {
var newItem = {
"ingrediente_id": val.id_tipo_ingredienti,
"quantita": val.quantita,
"tipo_quantita_id": val.id_tipo_quantita,
"note": escape(unescape(val.note))
};
sendobj.ingredienti.push(newItem);
});
$.ajax({
url: myManifest.Settings.DefaultURL + "/backend/ricetta/body",
//dataType: "json",
type: 'POST',
data: {bodydata: JSON.stringify(sendobj)}
}).then(function(response) {
if(callback)
callback(response);
});
}
else
alert("Inserire almeno categoria e titolo");
},
//render the content into div of view
render: function() {
//this.header.title = "pippo";
@@ -339,14 +381,20 @@ define(['jquery', 'underscore', 'backbone', 'text!modules/editricetta/editricett
uploadUrl: myManifest.Settings.DefaultURL + '/backend/photo' });
$('#jqxFileUpload').on('uploadStart', function (event) {
var profileID = "10203753344023406";
self.save(function(msg){
//alert(msg.message);
if (msg.result)
{
var profileID = "10203753344023406";
if($("#autorePhoto").val() != 0)
profileID = $("#autorePhoto").val();
if($("#autorePhoto").val() != 0)
profileID = $("#autorePhoto").val();
$('form[action="' + myManifest.Settings.DefaultURL + '/backend/photo' + '"]').
append('<input type="hidden" name="ricetta_id" value="' + self.ricettaEditing.ricetta_id +'" />').
append('<input type="hidden" name="keyStore" value="' + profileID + '" />');
$('form[action="' + myManifest.Settings.DefaultURL + '/backend/photo' + '"]').
append('<input type="hidden" name="ricetta_id" value="' + msg.ricettaID +'" />').
append('<input type="hidden" name="keyStore" value="' + profileID + '" />');
}
});
});
$('#jqxFileUpload').on('uploadEnd', function (event) {
$("#gridPhotos").jqxGrid('updatebounddata');
@@ -426,47 +474,11 @@ define(['jquery', 'underscore', 'backbone', 'text!modules/editricetta/editricett
$("#Save").jqxButton({width: '48%', height: 40});
$('#Save').on('click', function() {
if (self.validate()) {
var diffi = $('#lvlDiff').val();
var ingr = $('#listbox').jqxListBox('source');
var sendobj = {
"ricettaID": $("#ricettaID").val(),
"categoria_id": $("#categoria").val(),
"titolo": escape($("#titolo").val()),
"ingredienti": [],
"preparazione": $("#procedimento").val(),
"autore": escape($("#autore").val()),
"linkFonte": $("#linkFonte").val(),
"linkVideo": $("#linkYouTube").val(),
"difficolta": diffi
};
$.each(ingr, function(i, val) {
var newItem = {
"ingrediente_id": val.id_tipo_ingredienti,
"quantita": val.quantita,
"tipo_quantita_id": val.id_tipo_quantita,
"note": escape(unescape(val.note))
};
sendobj.ingredienti.push(newItem);
});
$.ajax({
url: myManifest.Settings.DefaultURL + "/backend/ricetta/body",
//dataType: "json",
type: 'POST',
data: {bodydata: JSON.stringify(sendobj)}
}).then(function(response) {
var msg = response;
alert(msg.message);
if (msg.result)
$("#popupWindow").jqxWindow('close');
});
}
else
alert("Inserire almeno categoria e titolo");
self.save(function(msg){
alert(msg.message);
if (msg.result)
$("#popupWindow").jqxWindow('close');
});
});
$("#Cancel").jqxButton({width: '48%', height: 40});