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
+3 -1
View File
@@ -2,7 +2,9 @@ var myManifest = {
Debug: (window.location.port !== ""), Debug: (window.location.port !== ""),
Name: "Il Management", Name: "Il Management",
Version: "0.3.0.0", Version: "0.3.0.0",
Author: "Denis Ironi", <<<<<<< .mine Version: "0.2.1.0",
======= Version: "0.3.0.0",
>>>>>>> .theirs Author: "Denis Ironi",
Settings: { Settings: {
DefaultURL: (window.location.port === "" ? "http://" + window.location.host + "/Service": "http://" + window.location.hostname + ":" + window.location.port + "/Service_Manut"), DefaultURL: (window.location.port === "" ? "http://" + window.location.host + "/Service": "http://" + window.location.hostname + ":" + window.location.port + "/Service_Manut"),
JQueryVersion: "1.11.1", JQueryVersion: "1.11.1",
+50 -38
View File
@@ -84,6 +84,48 @@ define(['jquery', 'underscore', 'backbone', 'text!modules/editricetta/editricett
return true; return true;
return false; 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 the content into div of view
render: function() { render: function() {
//this.header.title = "pippo"; //this.header.title = "pippo";
@@ -339,14 +381,20 @@ define(['jquery', 'underscore', 'backbone', 'text!modules/editricetta/editricett
uploadUrl: myManifest.Settings.DefaultURL + '/backend/photo' }); uploadUrl: myManifest.Settings.DefaultURL + '/backend/photo' });
$('#jqxFileUpload').on('uploadStart', function (event) { $('#jqxFileUpload').on('uploadStart', function (event) {
self.save(function(msg){
//alert(msg.message);
if (msg.result)
{
var profileID = "10203753344023406"; var profileID = "10203753344023406";
if($("#autorePhoto").val() != 0) if($("#autorePhoto").val() != 0)
profileID = $("#autorePhoto").val(); profileID = $("#autorePhoto").val();
$('form[action="' + myManifest.Settings.DefaultURL + '/backend/photo' + '"]'). $('form[action="' + myManifest.Settings.DefaultURL + '/backend/photo' + '"]').
append('<input type="hidden" name="ricetta_id" value="' + self.ricettaEditing.ricetta_id +'" />'). append('<input type="hidden" name="ricetta_id" value="' + msg.ricettaID +'" />').
append('<input type="hidden" name="keyStore" value="' + profileID + '" />'); append('<input type="hidden" name="keyStore" value="' + profileID + '" />');
}
});
}); });
$('#jqxFileUpload').on('uploadEnd', function (event) { $('#jqxFileUpload').on('uploadEnd', function (event) {
$("#gridPhotos").jqxGrid('updatebounddata'); $("#gridPhotos").jqxGrid('updatebounddata');
@@ -426,47 +474,11 @@ define(['jquery', 'underscore', 'backbone', 'text!modules/editricetta/editricett
$("#Save").jqxButton({width: '48%', height: 40}); $("#Save").jqxButton({width: '48%', height: 40});
$('#Save').on('click', function() { $('#Save').on('click', function() {
if (self.validate()) { self.save(function(msg){
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); alert(msg.message);
if (msg.result) if (msg.result)
$("#popupWindow").jqxWindow('close'); $("#popupWindow").jqxWindow('close');
}); });
}
else
alert("Inserire almeno categoria e titolo");
}); });
$("#Cancel").jqxButton({width: '48%', height: 40}); $("#Cancel").jqxButton({width: '48%', height: 40});
+4 -1
View File
@@ -114,13 +114,16 @@ define(['jquery', 'underscore', 'backbone', 'text!modules/ricette/ricetteViewTem
return "Elimina"; return "Elimina";
}, },
buttonclick: function(row) { buttonclick: function(row) {
var items = $("#jqxgrid").jqxGrid('source');
var item = items.records[row];
$.ajax({ $.ajax({
url: myManifest.Settings.DefaultURL + "/backend/ricetta/" + row.id, url: myManifest.Settings.DefaultURL + "/backend/ricetta/" + item.ricetta_id,
//dataType: "json", //dataType: "json",
type: 'DELETE' type: 'DELETE'
}).then(function (response) { }).then(function (response) {
var msg = response; var msg = response;
alert(msg.message); alert(msg.message);
$("#jqxgrid").jqxGrid('updatebounddata');
}); });
} }
} }