git-svn-id: https://msi/svn/firstRepo/Management/trunk@91 0f545695-f87b-41b6-9a03-7f16563b5454
This commit is contained in:
@@ -0,0 +1,302 @@
|
|||||||
|
|
||||||
|
define(['jquery', 'underscore', 'backbone', 'text!modules/editmulino/editmulinoViewTemplate.html', 'modules/base/baseView',
|
||||||
|
'controls/window/window', 'modules/addingr/addingr', 'jqx'],
|
||||||
|
function($, _, Backbone, editmulinoViewTemplate, BaseView, Window, AddIngrDlg) {
|
||||||
|
var FarineEnum = {
|
||||||
|
Tipo00: 1,
|
||||||
|
Tipo0: 2,
|
||||||
|
Tipo1: 4,
|
||||||
|
Integrale: 8,
|
||||||
|
Manitoba: 16,
|
||||||
|
Semola: 32,
|
||||||
|
Speciale: 64
|
||||||
|
};
|
||||||
|
|
||||||
|
var MacinaturaEnum = {
|
||||||
|
Rulli: 1,
|
||||||
|
Pietra: 2
|
||||||
|
};
|
||||||
|
|
||||||
|
var EditMuliniView = BaseView.extend({
|
||||||
|
dataAdapter: undefined,
|
||||||
|
//initialize template
|
||||||
|
template: _.template(editmulinoViewTemplate),
|
||||||
|
addIngrDlg: null,
|
||||||
|
fullScrDlg: null,
|
||||||
|
initialize: function() {
|
||||||
|
EditMuliniView.__super__.initialize.call(this);
|
||||||
|
//this.header.title = "pippo";
|
||||||
|
},
|
||||||
|
mulinoEditing: null,
|
||||||
|
checkValue: function(val, check){
|
||||||
|
return (val & check) == check;
|
||||||
|
},
|
||||||
|
openMulino: function(mulino_id) {
|
||||||
|
|
||||||
|
if (mulino_id)
|
||||||
|
{
|
||||||
|
var self = this;
|
||||||
|
$.ajax({
|
||||||
|
url: myManifest.Settings.DefaultURL + "/backend/mulino/body/" + mulino_id,
|
||||||
|
dataType: "jsonp",
|
||||||
|
crossDomain: true
|
||||||
|
}).then(function(response) {
|
||||||
|
var mulino = response[0];
|
||||||
|
self.mulinoEditing = mulino;
|
||||||
|
$('#jqxTabs').jqxTabs('select', 0);
|
||||||
|
$("#mulinoID").val(mulino.mulino_id);
|
||||||
|
$("#nomeMulino").val(unescape(mulino.nome));
|
||||||
|
$("#email").val(mulino.email);
|
||||||
|
$("#telefono").val(mulino.telefono);
|
||||||
|
$("#linkWebSite").val(mulino.linkWebSite);
|
||||||
|
$('#address').val(unescape(mulino.address));
|
||||||
|
$('#comune').val(unescape(mulino.comune));
|
||||||
|
$('#CAP').val(mulino.CAP);
|
||||||
|
$('#provincia').val(mulino.provincia);
|
||||||
|
$('#regione').val(mulino.regione);
|
||||||
|
|
||||||
|
// show the popup window.
|
||||||
|
$("#popupWindow").jqxWindow('open');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$('#jqxTabs').jqxTabs('select', 0);
|
||||||
|
// $("#mulinoID").val('');
|
||||||
|
// $("#categoria").jqxDropDownList('selectIndex', -1 );
|
||||||
|
// $("#titolo").val('');
|
||||||
|
// $("#autore").val('');
|
||||||
|
// $("#lvlDiff").val(0);
|
||||||
|
// $("#linkFonte").val('');
|
||||||
|
// $("#linkYouTube").val('');
|
||||||
|
// $('#procedimento').val('');
|
||||||
|
|
||||||
|
$("#popupWindow").jqxWindow('open');
|
||||||
|
}
|
||||||
|
},
|
||||||
|
validate: function()
|
||||||
|
{
|
||||||
|
if ($("#categoria").val() > 0 &&
|
||||||
|
$("#titolo").val() !== "")
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
},
|
||||||
|
save:function(callback)
|
||||||
|
{
|
||||||
|
if (this.validate()) {
|
||||||
|
var diffi = $('#lvlDiff').val();
|
||||||
|
|
||||||
|
var ingr = $('#listbox').jqxListBox('source');
|
||||||
|
|
||||||
|
var sendobj = {
|
||||||
|
"mulinoID": $("#mulinoID").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/mulino/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";
|
||||||
|
EditMuliniView.__super__.render.call(this);
|
||||||
|
var self = this;
|
||||||
|
|
||||||
|
this.$el.append(this.template());
|
||||||
|
|
||||||
|
this.$el.find("#popupWindow").jqxWindow({
|
||||||
|
width: "750px",
|
||||||
|
height: "500px",
|
||||||
|
resizable: true,
|
||||||
|
isModal: true,
|
||||||
|
autoOpen: false,
|
||||||
|
cancelButton: this.$el.find("#Cancel"),
|
||||||
|
modalOpacity: 0.01,
|
||||||
|
initContent: function() {
|
||||||
|
$('#jqxTabs').jqxTabs({
|
||||||
|
width: '100%',
|
||||||
|
height: "90%",
|
||||||
|
position: 'top',
|
||||||
|
initTabContent: function(tab) {
|
||||||
|
if (tab === 0)
|
||||||
|
{
|
||||||
|
$("#nomeMulino").jqxInput({placeHolder: "Nome:", width: '350px', height: 25});
|
||||||
|
$("#email").jqxInput({placeHolder: "Email:", width: '350px', height: 25});
|
||||||
|
$("#telefono").jqxInput({placeHolder: "Telefono:", width: '350px', height: 25});
|
||||||
|
$("#linkWebSite").jqxInput({placeHolder: "Sito Web:", width: '350px', height: 25});
|
||||||
|
|
||||||
|
$('#logoUpload').jqxFileUpload({ width: '50%',
|
||||||
|
fileInputName: 'image',
|
||||||
|
multipleFilesUpload: false,
|
||||||
|
accept: 'image/*',
|
||||||
|
uploadUrl: myManifest.Settings.DefaultURL + '/backend/photo/mulino' });
|
||||||
|
|
||||||
|
$('#logoUpload').on('uploadStart', function (event) {
|
||||||
|
$('form[action="' + myManifest.Settings.DefaultURL + '/backend/photo/mulino' + '"]').
|
||||||
|
append('<input type="hidden" name="mulino_name" value="' + escape($("#nomeMulino").val()) +'" />');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else if (tab === 1)
|
||||||
|
{
|
||||||
|
$("#address").jqxInput({placeHolder: "Indirizzo:", width: '350px', height: 25});
|
||||||
|
$("#provincia").jqxInput({placeHolder: "Provincia:", width: '350px', height: 25,
|
||||||
|
source: function (query, response) {
|
||||||
|
var dataAdapter = new $.jqx.dataAdapter
|
||||||
|
(
|
||||||
|
{
|
||||||
|
datatype: "jsonp",
|
||||||
|
datafields:
|
||||||
|
[
|
||||||
|
{ name: 'Provincia' },
|
||||||
|
{ name: 'Regione' }
|
||||||
|
],
|
||||||
|
url: myManifest.Settings.DefaultURL + "/profile/province/"+query
|
||||||
|
},
|
||||||
|
{
|
||||||
|
autoBind: true,
|
||||||
|
loadComplete: function (data) {
|
||||||
|
response(data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
$("#comune").jqxInput({placeHolder: "Comune:", width: '350px', height: 25,
|
||||||
|
source: function (query, response) {
|
||||||
|
var dataAdapter = new $.jqx.dataAdapter
|
||||||
|
(
|
||||||
|
{
|
||||||
|
datatype: "jsonp",
|
||||||
|
datafields:
|
||||||
|
[
|
||||||
|
{ name: 'Comune' },
|
||||||
|
{ name: 'CAP' }
|
||||||
|
],
|
||||||
|
url: myManifest.Settings.DefaultURL + "/profile/comuni/" + $("#provincia").val() + "/"+query
|
||||||
|
},
|
||||||
|
{
|
||||||
|
autoBind: true,
|
||||||
|
loadComplete: function (data) {
|
||||||
|
response(data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
$("#CAP").jqxInput({placeHolder: "CAP:", width: '350px', height: 25});
|
||||||
|
$("#regione").jqxInput({placeHolder: "Regione:", width: '350px', height: 25});
|
||||||
|
}
|
||||||
|
else if (tab === 3)
|
||||||
|
{
|
||||||
|
$("#farine").jqxDropDownList(
|
||||||
|
{
|
||||||
|
width: "250px",
|
||||||
|
height: "25px",
|
||||||
|
source: new $.jqx.dataAdapter({
|
||||||
|
datatype: 'array',
|
||||||
|
datafields: [
|
||||||
|
{name: 'value'},
|
||||||
|
{name: 'label'}
|
||||||
|
],
|
||||||
|
localdata: [
|
||||||
|
{value: '1', label: 'Tipo00'},
|
||||||
|
{value: '2', label: 'Tipo0'},
|
||||||
|
{value: '4', label: 'Tipo1'},
|
||||||
|
{value: '8', label: 'Integrale'},
|
||||||
|
{value: '16', label: 'Manitoba'},
|
||||||
|
{value: '32', label: 'Semola'},
|
||||||
|
{value: '64', label: 'Speciale'}
|
||||||
|
]
|
||||||
|
}),
|
||||||
|
//selectedIndex: -1,
|
||||||
|
displayMember: "label",
|
||||||
|
valueMember: "value"
|
||||||
|
});
|
||||||
|
$("#farSpeciali").jqxInput({placeHolder: "Farine Speciali:", width: '350px', height: 25});
|
||||||
|
$("#macinatura").jqxDropDownList(
|
||||||
|
{
|
||||||
|
width: "250px",
|
||||||
|
height: "25px",
|
||||||
|
source: new $.jqx.dataAdapter({
|
||||||
|
datatype: 'array',
|
||||||
|
datafields: [
|
||||||
|
{name: 'value'},
|
||||||
|
{name: 'label'}
|
||||||
|
],
|
||||||
|
localdata: [
|
||||||
|
{value: '1', label: 'Rulli'},
|
||||||
|
{value: '2', label: 'Pietra'}
|
||||||
|
]
|
||||||
|
}),
|
||||||
|
//selectedIndex: -1,
|
||||||
|
displayMember: "label",
|
||||||
|
valueMember: "value"
|
||||||
|
});
|
||||||
|
|
||||||
|
$("#prezzo").jqxSlider({height: 60, min: 0, max: 10, value: 0, step: 0.10});
|
||||||
|
|
||||||
|
var text = $('#spedizione').val();
|
||||||
|
$('#spedizione').jqxEditor({width: '100%', height: "20%"});
|
||||||
|
if (text)
|
||||||
|
$('#spedizione').jqxEditor('val', text);
|
||||||
|
}
|
||||||
|
else if (tab === 3)
|
||||||
|
{
|
||||||
|
var text = $('#procedimento').val();
|
||||||
|
$('#procedimento').jqxEditor({width: '100%', height: "50%"});
|
||||||
|
if (text)
|
||||||
|
$('#procedimento').jqxEditor('val', text);
|
||||||
|
|
||||||
|
var text = $('#note').val();
|
||||||
|
$('#note').jqxEditor({width: '100%', height: "50%"});
|
||||||
|
if (text)
|
||||||
|
$('#note').jqxEditor('val', text);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
$("#Save").jqxButton({width: '48%', height: 40});
|
||||||
|
|
||||||
|
$('#Save').on('click', function() {
|
||||||
|
self.save(function(msg){
|
||||||
|
alert(msg.message);
|
||||||
|
if (msg.result)
|
||||||
|
$("#popupWindow").jqxWindow('close');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
$("#Cancel").jqxButton({width: '48%', height: 40});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return EditMuliniView;
|
||||||
|
});
|
||||||
@@ -0,0 +1,87 @@
|
|||||||
|
<div id="content">
|
||||||
|
<div id="popupWindow" style="overflow: hidden; display: none;">
|
||||||
|
<div>Edit</div>
|
||||||
|
<div>
|
||||||
|
<input type="hidden" id="mulinoID" />
|
||||||
|
<div id='jqxTabs'>
|
||||||
|
<ul>
|
||||||
|
<li style="margin-left: 30px;">Informazioni Generali</li>
|
||||||
|
<li>Indirizzo</li>
|
||||||
|
<li>Farine</li>
|
||||||
|
<li>Descrizione</li>
|
||||||
|
</ul>
|
||||||
|
<div>
|
||||||
|
<table>
|
||||||
|
<tr>
|
||||||
|
<td align="right">Nome:</td>
|
||||||
|
<td align="left"><input id="nomeMulino" /></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td align="right">Logo:</td>
|
||||||
|
<td align="left"><div id='logoUpload'></div></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td align="right">Email:</td>
|
||||||
|
<td align="left"><input id="email" /></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td align="right">Telefono:</td>
|
||||||
|
<td align="left"><input id="telefono" /></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td align="right">Sito Web:</td>
|
||||||
|
<td align="left"><input id="linkWebSite" /></td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<table>
|
||||||
|
<tr>
|
||||||
|
<td align="right">Indirizzo:</td>
|
||||||
|
<td align="left"><input id="address" /></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td align="right">Provincia:</td>
|
||||||
|
<td align="left"><div id="provincia" /> Regione: <div id="regione" /></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td align="right">Comune:</td>
|
||||||
|
<td align="left"><input id='comune'></div></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td align="right">CAP:</td>
|
||||||
|
<td align="left"><input id="CAP" /></td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<table>
|
||||||
|
<tr>
|
||||||
|
<td align="right">Farine:</td>
|
||||||
|
<td align="left"><div id="farine" /></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td align="right">Specifica Speciali:</td>
|
||||||
|
<td align="left"><input id='farSpeciali'></div></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td align="right">Macinatura:</td>
|
||||||
|
<td align="left"><div id='macinatura'></div></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td align="right">Prezzo (Min-Max):</td>
|
||||||
|
<td align="left"><div id='prezzo'></div></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td align="right">Spedizione:</td>
|
||||||
|
<td align="left"><textarea id='spedizione'></textarea></td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
<div><textarea id="descrizione"></textarea>
|
||||||
|
<textarea id="note"></textarea></div>
|
||||||
|
</div>
|
||||||
|
<input style="margin-right: 5px;" type="button" id="Save" value="Save" /><input id="Cancel" type="button" value="Cancel" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
+62
-4
@@ -1,13 +1,19 @@
|
|||||||
define(['jquery', 'underscore', 'backbone', 'text!modules/home/homeViewTemplate.html',
|
define(['jquery', 'underscore', 'backbone', 'text!modules/home/homeViewTemplate.html', 'modules/base/baseView',
|
||||||
'modules/base/baseView', 'modules/ricette/ricette', 'modules/editricetta/editricetta', 'modules/photos/photos', 'modules/statistics/statistics',
|
'modules/ricette/ricette', 'modules/editricetta/editricetta', 'modules/editricetta/editricetta',
|
||||||
'modules/editricetta/editricetta', 'text!modules/home/inputWindow.html',
|
'modules/mulini/mulini', 'modules/editmulino/editmulino', 'modules/editmulino/editmulino',
|
||||||
|
'modules/photos/photos', 'modules/statistics/statistics', 'text!modules/home/inputWindow.html',
|
||||||
'jqx'],
|
'jqx'],
|
||||||
function($, _, Backbone, homeViewTemplate, BaseView, RicetteView, EditRicettaView, PhotosView, StatisticsView, EditRicetta, inputWindowTemplate) {
|
function($, _, Backbone, homeViewTemplate, BaseView,
|
||||||
|
RicetteView, EditRicettaView, EditRicetta,
|
||||||
|
MuliniView, EditMulinoView, EditMulino,
|
||||||
|
PhotosView, StatisticsView, inputWindowTemplate) {
|
||||||
|
|
||||||
var HomeView = BaseView.extend({
|
var HomeView = BaseView.extend({
|
||||||
ricetteView: null,
|
ricetteView: null,
|
||||||
|
muliniView: null,
|
||||||
statiView: null,
|
statiView: null,
|
||||||
editorRicetta: null,
|
editorRicetta: null,
|
||||||
|
editorMulino: null,
|
||||||
//initialize template
|
//initialize template
|
||||||
template: _.template(homeViewTemplate),
|
template: _.template(homeViewTemplate),
|
||||||
templateInputWindow: _.template(inputWindowTemplate),
|
templateInputWindow: _.template(inputWindowTemplate),
|
||||||
@@ -56,6 +62,43 @@ define(['jquery', 'underscore', 'backbone', 'text!modules/home/homeViewTemplate.
|
|||||||
$('#ricettaId').focus();
|
$('#ricettaId').focus();
|
||||||
|
|
||||||
},
|
},
|
||||||
|
addMulino: function() {
|
||||||
|
var editMuliniView = new EditMulinoView();
|
||||||
|
editMuliniView.render();
|
||||||
|
$('body').append(editMuliniView.$el);
|
||||||
|
editMuliniView.openMulino();
|
||||||
|
},
|
||||||
|
modifyMulino: function() {
|
||||||
|
if(this.muliniView == null)
|
||||||
|
{
|
||||||
|
this.muliniView = new MuliniView();
|
||||||
|
this.muliniView.render();
|
||||||
|
$('body').append(this.muliniView.$el);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
this.muliniView.render();
|
||||||
|
},
|
||||||
|
modifyByIDMulino: function() {
|
||||||
|
var self = this;
|
||||||
|
if(this.editorMulino == null)
|
||||||
|
{
|
||||||
|
this.editorMulino = new EditMulino();
|
||||||
|
this.editorMulino.render();
|
||||||
|
$('body').append(this.editorMulino.$el);
|
||||||
|
}
|
||||||
|
$('#openBtn').off('click');
|
||||||
|
$('#openBtn').on('click', function () {
|
||||||
|
$('#inputWindow').jqxWindow('close');
|
||||||
|
self.editorMulino.openMulino($('#mulinoId').val());
|
||||||
|
});
|
||||||
|
$('#cancelButton').off('click');
|
||||||
|
$('#cancelButton').on('click', function () {
|
||||||
|
$('#inputWindow').jqxWindow('close');
|
||||||
|
});
|
||||||
|
$('#mulinoId').val("");
|
||||||
|
$('#inputWindow').jqxWindow('open');
|
||||||
|
$('#mulinoId').focus();
|
||||||
|
},
|
||||||
photosView: function(){
|
photosView: function(){
|
||||||
var photosView = new PhotosView();
|
var photosView = new PhotosView();
|
||||||
photosView.render();
|
photosView.render();
|
||||||
@@ -89,6 +132,21 @@ define(['jquery', 'underscore', 'backbone', 'text!modules/home/homeViewTemplate.
|
|||||||
{
|
{
|
||||||
event.data.scope.modifyByIDRicetta();
|
event.data.scope.modifyByIDRicetta();
|
||||||
}
|
}
|
||||||
|
else if(item[0].id === "addMulino" ||
|
||||||
|
item[0].lastChild.id === "addMulino")
|
||||||
|
{
|
||||||
|
event.data.scope.addMulino();
|
||||||
|
}
|
||||||
|
else if(item[0].id === "modifyMulino" ||
|
||||||
|
item[0].lastChild.id === "modifyMulino")
|
||||||
|
{
|
||||||
|
event.data.scope.modifyMulino();
|
||||||
|
}
|
||||||
|
else if(item[0].id === "modifyByIDMulino" ||
|
||||||
|
item[0].lastChild.id === "modifyByIDMulino")
|
||||||
|
{
|
||||||
|
event.data.scope.modifyByIDMulino();
|
||||||
|
}
|
||||||
else if(item[0].id === "viewPhotos" ||
|
else if(item[0].id === "viewPhotos" ||
|
||||||
item[0].lastChild.id === "viewPhotos")
|
item[0].lastChild.id === "viewPhotos")
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -8,6 +8,13 @@
|
|||||||
<li><a id="modifyByIDRicetta" href="#">Modifica per ID</a></li>
|
<li><a id="modifyByIDRicetta" href="#">Modifica per ID</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
|
<li>Gestione Mulini
|
||||||
|
<ul style='width: 250px;'>
|
||||||
|
<li><a id="modifyMulino" href="#">Lista</a></li>
|
||||||
|
<li><a id="addMulino" href="#">Aggiungi</a></li>
|
||||||
|
<li><a id="modifyByIDMulino" href="#">Modifica per ID</a></li>
|
||||||
|
</ul>
|
||||||
|
</li>
|
||||||
<!--
|
<!--
|
||||||
<li>Ingredienti
|
<li>Ingredienti
|
||||||
<ul style='width: 250px;'>
|
<ul style='width: 250px;'>
|
||||||
|
|||||||
@@ -0,0 +1,120 @@
|
|||||||
|
define(['jquery', 'underscore', 'backbone', 'text!modules/mulini/muliniViewTemplate.html', 'modules/base/baseView',
|
||||||
|
'controls/window/window', 'modules/editmulino/editmulino', 'jqx'],
|
||||||
|
function($, _, Backbone, muliniViewTemplate, BaseView, Window, EditMulino) {
|
||||||
|
|
||||||
|
var MuliniView = BaseView.extend({
|
||||||
|
dataAdapter: undefined,
|
||||||
|
//initialize template
|
||||||
|
template: _.template(muliniViewTemplate),
|
||||||
|
window:null,
|
||||||
|
editorMulino: null,
|
||||||
|
|
||||||
|
initialize: function() {
|
||||||
|
MuliniView.__super__.initialize.call(this);
|
||||||
|
//this.header.title = "pippo";
|
||||||
|
},
|
||||||
|
openMulino: function(row) {
|
||||||
|
var editrow = row;
|
||||||
|
var dataRecord = $("#jqxgrid").jqxGrid('getrowdata', editrow);
|
||||||
|
this.editorMulino.openMulino(dataRecord.mulino_id);
|
||||||
|
},
|
||||||
|
//render the content into div of view
|
||||||
|
render: function() {
|
||||||
|
//this.header.title = "pippo";
|
||||||
|
MuliniView.__super__.render.call(this);
|
||||||
|
var self = this;
|
||||||
|
|
||||||
|
if(self.window === null)
|
||||||
|
{
|
||||||
|
self.window = new Window({
|
||||||
|
id: "mulini",
|
||||||
|
title: "Mulini",
|
||||||
|
width: "850px",
|
||||||
|
resizable: true,
|
||||||
|
height: "510px",
|
||||||
|
maxHeight: 1000,
|
||||||
|
maxWidth: 1000,
|
||||||
|
content: "<p><div id=\"jqxgrid\"></div></p>",
|
||||||
|
initContentFn: function() {
|
||||||
|
// prepare the data
|
||||||
|
self.dataAdapter = new $.jqx.dataAdapter({
|
||||||
|
datatype: "jsonp",
|
||||||
|
datafields: [
|
||||||
|
{name: 'mulino_id', type: 'int'},
|
||||||
|
{name: 'nome', type: 'string'},
|
||||||
|
{name: 'regione', type: 'string'}
|
||||||
|
],
|
||||||
|
id: 'mulino_id',
|
||||||
|
url: myManifest.Settings.DefaultURL + "/backend/mulini"
|
||||||
|
});
|
||||||
|
$("#jqxgrid").jqxGrid({
|
||||||
|
width: "100%",
|
||||||
|
height: "95%",
|
||||||
|
source: self.dataAdapter,
|
||||||
|
filterable: true,
|
||||||
|
autoshowfiltericon: true,
|
||||||
|
columns: [
|
||||||
|
{text: 'Titolo', dataField: 'titolo', width: "50%",
|
||||||
|
cellsrenderer: function(row, columnfield, value, defaulthtml, columnproperties) {
|
||||||
|
return "<div style='overflow: hidden; text-overflow: ellipsis; padding-bottom: 2px; text-align: left; margin-right: 2px; margin-left: 4px; margin-top: 4px;'>" + unescape(value ) + "</div>";
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{text: 'Autore', dataField: 'autore', width: "30%",
|
||||||
|
cellsrenderer: function(row, columnfield, value, defaulthtml, columnproperties) {
|
||||||
|
return "<div style='overflow: hidden; text-overflow: ellipsis; padding-bottom: 2px; text-align: left; margin-right: 2px; margin-left: 4px; margin-top: 4px;'>" + unescape(value ) + "</div>";
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{text: '', datafield: 'Edit', columntype: 'button', width: '10%', filterable: false, sortable: false, menu: false,
|
||||||
|
cellsrenderer: function() {
|
||||||
|
return "Modifica";
|
||||||
|
},
|
||||||
|
buttonclick: function(row) {
|
||||||
|
self.openMulino(row);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{text: '', datafield: 'Del', columntype: 'button', width: '10%', filterable: false, sortable: false, menu: false,
|
||||||
|
cellsrenderer: function() {
|
||||||
|
return "Elimina";
|
||||||
|
},
|
||||||
|
buttonclick: function(row) {
|
||||||
|
var items = $("#jqxgrid").jqxGrid('source');
|
||||||
|
var item = items.records[row];
|
||||||
|
$.ajax({
|
||||||
|
url: myManifest.Settings.DefaultURL + "/backend/mulino/" + item.mulino_id,
|
||||||
|
//dataType: "json",
|
||||||
|
type: 'DELETE'
|
||||||
|
}).then(function (response) {
|
||||||
|
var msg = response;
|
||||||
|
alert(msg.message);
|
||||||
|
$("#jqxgrid").jqxGrid('updatebounddata');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#jqxgrid').on('rowdoubleclick', function(event)
|
||||||
|
{
|
||||||
|
var args = event.args;
|
||||||
|
var row = args.rowindex;
|
||||||
|
self.openMulino(row);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
this.$el.append(this.template());
|
||||||
|
this.$el.find("#content").append(self.window.$el);
|
||||||
|
self.window.render();
|
||||||
|
|
||||||
|
this.editorMulino = new EditMulino();
|
||||||
|
this.$el.find("#content").append(this.editorMulino.$el);
|
||||||
|
|
||||||
|
this.editorMulino.render();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
self.window.open();
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return MuliniView;
|
||||||
|
});
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
<div id="content">
|
||||||
|
</div>
|
||||||
Reference in New Issue
Block a user