diff --git a/js/manifest.js b/js/manifest.js
index e14ee7d..a8573fb 100644
--- a/js/manifest.js
+++ b/js/manifest.js
@@ -2,7 +2,9 @@ var myManifest = {
Debug: (window.location.port !== ""),
Name: "Il Management",
Version: "0.3.0.0",
- Author: "Denis Ironi",
+<<<<<<< .mine Version: "0.2.1.0",
+======= Version: "0.3.0.0",
+>>>>>>> .theirs Author: "Denis Ironi",
Settings: {
DefaultURL: (window.location.port === "" ? "http://" + window.location.host + "/Service": "http://" + window.location.hostname + ":" + window.location.port + "/Service_Manut"),
JQueryVersion: "1.11.1",
diff --git a/js/modules/editricetta/editricetta.js b/js/modules/editricetta/editricetta.js
index c7f4092..0aff9ac 100644
--- a/js/modules/editricetta/editricetta.js
+++ b/js/modules/editricetta/editricetta.js
@@ -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('').
- append('');
+ $('form[action="' + myManifest.Settings.DefaultURL + '/backend/photo' + '"]').
+ append('').
+ append('');
+ }
+ });
});
$('#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});
diff --git a/js/modules/ricette/ricette.js b/js/modules/ricette/ricette.js
index 420b674..9ad00d8 100644
--- a/js/modules/ricette/ricette.js
+++ b/js/modules/ricette/ricette.js
@@ -114,13 +114,16 @@ define(['jquery', 'underscore', 'backbone', 'text!modules/ricette/ricetteViewTem
return "Elimina";
},
buttonclick: function(row) {
+ var items = $("#jqxgrid").jqxGrid('source');
+ var item = items.records[row];
$.ajax({
- url: myManifest.Settings.DefaultURL + "/backend/ricetta/" + row.id,
+ url: myManifest.Settings.DefaultURL + "/backend/ricetta/" + item.ricetta_id,
//dataType: "json",
type: 'DELETE'
}).then(function (response) {
var msg = response;
alert(msg.message);
+ $("#jqxgrid").jqxGrid('updatebounddata');
});
}
}