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

This commit is contained in:
2014-12-10 14:48:17 +00:00
parent 9ce880f5cc
commit a3e66c67a7
595 changed files with 52238 additions and 0 deletions
+30
View File
@@ -0,0 +1,30 @@
define(['jquery', 'underscore', 'backbone','text!modules/about/aboutViewTemplate.html', 'modules/base/baseView'],
function($, _, Backbone, aboutViewTemplate, BaseView){
var AboutView = BaseView.extend({
//initialize template
template:_.template(aboutViewTemplate),
initialize: function () {
AboutView.__super__.initialize.call(this);
},
//render the content into div of view
render: function(){
//this.header.title = "pippo";
AboutView.__super__.render.call(this);
//this.el is the root element of Backbone.View. By default, it is a div.
//$el is cached jQuery object for the view's element.
//append the compiled template into view div container
this.$el.append(this.header.$el);
this.$el.append(this.template( { app: myManifest }));
this.$el.append(this.footer.$el);
this.$el.find("#infoBtn").addClass("ui-btn-active");
//$("#homeBtn").addClass("ui-btn-active");
//return to enable chained calls
return this;
}
});
return AboutView;
});
+35
View File
@@ -0,0 +1,35 @@
<div data-role="content">
<br>
<center>
<h1 style='font-size: xx-large;'><%= app.Name %></h1>
<br>Applicazione Ricettario del Gruppo<br><br>'<i><b>La Pasta Madre</b></i>'<br><br>
<b>Versione:</b> <%= app.Version %><br><br>
<b>Sviluppatore:</b> <%= app.Author %><br><br>
<br><b>Dettagli Sviluppo: </b><br>S.O.:<%= app.Agent.os.name %><br>Versione: <%= app.Agent.os.version %><br><br>
<b>Librerie Usate: </b><br>JQuery:<%= app.Settings.JQueryVersion %><br>JQueryMobile: <%= app.Settings.JQueryMobileVersion %><br>
<br><br>
<b>Ringraziamenti a</b>
<br><br>
<i>Per il supporto morale e di coordinamento</i><br><br>
Alessia B. (Boss)<br>
Francesca M. (ViceBoss)<br><br>
<i>Per il codice del convertitore</i><br><br>
ringrazio l'autore Giuseppe Burgio<a href="http://www.pastamadre.eu/">PastaMadre</a><br><br>
<i>Per l'inserimento di tutte le ricette</i><br><br>
Angela P.<br>
Carlotta G.<br>
Cristina D.<br>
Daria M.o<br>
Giorgia B.<br>
Ire Piu' Pi<br>
Lucia A.<br>
Malek Ben C.<br>
Raffaella G.<br>
Rita M.<br>
Serenella S.<br>
Valentina C.<br>
Valentina D'a.<br>
Valentina V.<br>
Valentina Yaya C.<br>
</center>
</div>
+147
View File
@@ -0,0 +1,147 @@
define(['jquery', 'underscore', 'backbone', 'text!modules/addingr/addingrViewTemplate.html', 'modules/base/baseView',
'jqxbuttons', 'jqxdata', 'jqxdropdownlist',
'jqxinput', 'jqxrating', 'jqxnumberinput'],
function($, _, Backbone, addingrViewTemplate, BaseView) {
var AddIngrView = BaseView.extend({
dataAdapter: undefined,
//initialize template
template: _.template(addingrViewTemplate),
initialize: function() {
AddIngrView.__super__.initialize.call(this);
//this.header.title = "pippo";
},
openDlg: function()
{
$("#ingrediente").jqxDropDownList('selectedIndex', -1);
$("#unitMis").jqxDropDownList('selectedIndex', -1);
$("#qty").jqxNumberInput('val', '');
$("#nota").val('');
$("#addIngrWindow").jqxWindow('open');
},
validate: function() {
if ($("#ingrediente").val() === "22" && $("#nota").val() !== "")
return true;
if ($("#ingrediente").val() > 0 &&
$("#ingrediente").val() !== "22" &&
$("#qty").val() > 0 &&
$("#unitMis").val() > 0)
return true;
return false;
},
addBtnFn: undefined,
//render the content into div of view
render: function() {
//this.header.title = "pippo";
AddIngrView.__super__.render.call(this);
var self = this;
this.$el.append(this.template());
this.$el.find("#addIngrWindow").jqxWindow({
width: 350,
height: 230,
resizable: false,
isModal: true,
autoOpen: false,
cancelButton: this.$el.find("#cancelIngrBtn"),
modalOpacity: 0.01,
initContent: function() {
var source =
{
datatype: "jsonp",
datafields: [
{name: 'tipo_ingredienti_id'},
{name: 'name'}
],
url: myManifest.Settings.DefaultURL + "/backend/typeingredients",
data: {
}
};
var dataAdapter = new $.jqx.dataAdapter(source);
$("#ingrediente").jqxDropDownList(
{
width: 200,
height: 25,
source: dataAdapter,
selectedIndex: -1,
displayMember: "name",
valueMember: "tipo_ingredienti_id"
});
var sourceunitMis =
{
datatype: "jsonp",
datafields: [
{name: 'tipo_quantita_id'},
{name: 'name'}
],
url: myManifest.Settings.DefaultURL + "/backend/typeqtys",
data: {
}
};
var dataAdapterunitMis = new $.jqx.dataAdapter(sourceunitMis);
$("#unitMis").jqxDropDownList(
{
width: 200,
height: 25,
source: dataAdapterunitMis,
selectedIndex: -1,
displayMember: "name",
valueMember: "tipo_quantita_id"
});
$("#ingrediente").on('select', {scope: self}, function(event) {
if (event.args) {
var item = event.args.item;
if (item) {
if (item.value === "22")
{
$("#qty").jqxNumberInput({disabled: true});
$("#unitMis").jqxDropDownList({disabled: true});
}
else
{
$("#qty").jqxNumberInput({disabled: false});
$("#unitMis").jqxDropDownList({disabled: false});
}
}
}
});
$("#qty").jqxNumberInput({width: '250px', height: 25, decimal: 0.0, min: 0, decimalDigits: 0, digits: 4, groupSeparator: ''});
$("#nota").jqxInput({placeHolder: "Nota:", width: '250px', height: 45});
$("#addIngrBtn").jqxButton({width: '48%', height: 40});
$("#cancelIngrBtn").jqxButton({width: '48%', height: 40});
$("#addIngrBtn").on('click', function() {
if (self.validate())
{
var newItem = {
"id_tipo_ingredienti": $("#ingrediente").jqxDropDownList('getSelectedItem').value,
"nome_ingrediente": $("#ingrediente").jqxDropDownList('getSelectedItem').label,
"quantita": $("#qty").jqxNumberInput('val'),
"id_tipo_quantita": null,
"unita": null,
"note": $("#nota").val()
};
if($("#unitMis").jqxDropDownList('getSelectedItem') !== null)
newItem.unita = $("#unitMis").jqxDropDownList('getSelectedItem').label;
if($("#unitMis").jqxDropDownList('getSelectedItem') !== null)
newItem.id_tipo_quantita = $("#unitMis").jqxDropDownList('getSelectedItem').value;
if (self.addBtnFn)
self.addBtnFn(newItem);
$('#addIngrWindow').jqxWindow('close');
}
else
alert("Inserire correttamente i dati");
});
}
});
return this;
}
});
return AddIngrView;
});
@@ -0,0 +1,26 @@
<div id="content">
<div id="addIngrWindow" style="overflow: hidden; display: none;">
<div>Aggiungi Ingrediente</div>
<div>
<table>
<tr>
<td align="right">Ingrediente</td>
<td align="left"><div id="ingrediente"></div></td>
</tr>
<tr>
<td align="right">Quantità:</td>
<td align="left"><div id="qty"></div></td>
</tr>
<tr>
<td align="right">Unità di Misura:</td>
<td align="left"><div id='unitMis'></div></td>
</tr>
<tr>
<td align="right">Nota:</td>
<td align="left"><input id="nota" /></td>
</tr>
</table>
<input style="margin-right: 5px;" type="button" id="addIngrBtn" value="Save" /><input style="margin-left: 8px;" id="cancelIngrBtn" type="button" value="Cancel" />
</div>
</div>
</div>
+13
View File
@@ -0,0 +1,13 @@
define(['jquery', 'underscore', 'backbone'],
function($, _, Backbone){
var BaseView = Backbone.View.extend({
initialize: function () {
},
render: function(){
}
});
return BaseView;
});
+321
View File
@@ -0,0 +1,321 @@
define(['jquery', 'underscore', 'backbone', 'text!modules/editricetta/editricettaViewTemplate.html', 'modules/base/baseView',
'controls/window/window', 'modules/addingr/addingr', 'jqxbuttons', 'jqxgrid', 'jqxcombobox', 'jqxdata', 'jqxdropdownlist',
'jqxgrid', 'jqxgrid_selection', 'jqxgrid_columnsresize', 'jqxgrid_filter',
'jqxtabs', 'jqxeditor', 'jqxinput', 'jqxrating', 'jqxnumberinput', 'jqxlistbox'],
function($, _, Backbone, editricettaViewTemplate, BaseView, Window, AddIngrDlg) {
var EditRicetteView = BaseView.extend({
dataAdapter: undefined,
//initialize template
template: _.template(editricettaViewTemplate),
addIngrDlg: null,
initialize: function() {
EditRicetteView.__super__.initialize.call(this);
//this.header.title = "pippo";
},
ricettaEditing: null,
openRicetta: function(ricetta_id) {
if (ricetta_id)
{
var self = this;
$.ajax({
url: myManifest.Settings.DefaultURL + "/backend/ricetta/body/" + ricetta_id,
dataType: "jsonp",
crossDomain: true
}).then(function(response) {
var ricetta = response[0];
self.ricettaEditing = ricetta;
$('#jqxTabs').jqxTabs('select', 0);
$("#ricettaID").val(ricetta.ricetta_id);
$("#categoria").val(ricetta.id_categoria);
$("#titolo").val(unescape(ricetta.titolo));
$("#autore").val(unescape(ricetta.autore));
$("#lvlDiff").val(ricetta.difficolta);
$("#linkFonte").val(ricetta.link_fonte);
$("#linkYouTube").val(ricetta.link_youtube);
$('#procedimento').val(ricetta.procedimento);
$("#listbox").jqxListBox({source: ricetta.ingredienti, itemHeight: 30, height: '90%', width: '100%', theme: 'arctic'});
// show the popup window.
$("#popupWindow").jqxWindow('open');
});
}
else
{
$('#jqxTabs').jqxTabs('select', 0);
$("#ricettaID").val('');
$("#categoria").jqxDropDownList('selectIndex', -1 );
$("#titolo").val('');
$("#autore").val('');
$("#lvlDiff").val(0);
$("#linkFonte").val('');
$("#linkYouTube").val('');
$('#procedimento').val('');
$("#listbox").jqxListBox({source: []});
$("#popupWindow").jqxWindow('open');
}
},
validate: function()
{
if ($("#categoria").val() > 0 &&
$("#titolo").val() !== "")
return true;
return false;
},
//render the content into div of view
render: function() {
//this.header.title = "pippo";
EditRicetteView.__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)
{
// get the clicked row's data and initialize the input fields.
var source =
{
datatype: "jsonp",
datafields: [
{name: 'category_id'},
{name: 'name'}
],
url: myManifest.Settings.DefaultURL + "/backend/categories",
data: {
}
};
var dataAdapter = new $.jqx.dataAdapter(source);
$("#categoria").on('bindingComplete', function (event) {
if(self.ricettaEditing !== null)
$("#categoria").val(self.ricettaEditing.id_categoria);
});
$("#categoria").jqxDropDownList(
{
width: "350px",
height: "25px",
source: dataAdapter,
//selectedIndex: -1,
displayMember: "name",
valueMember: "category_id"
});
$("#titolo").jqxInput({placeHolder: "Titolo:", width: '350px', height: 25});
$("#autore").jqxInput({placeHolder: "Autore:", width: '350px', height: 25});
$("#lvlDiff").jqxRating({width: 350, height: 35, theme: 'classic'});
$("#linkFonte").jqxInput({placeHolder: "Link Fonte:", width: '350px', height: 25});
$("#linkYouTube").jqxInput({placeHolder: "Link Youtube:", width: '350px', height: 25});
}
else if (tab === 1)
{
$("#add").jqxButton({width: '37%'});
$("#remove").jqxButton({disabled: true, width: '37%'});
$('#add').on('click', function() {
self.addIngrDlg.openDlg();
});
$('#remove').on('click', function() {
var indexSelected = $('#listbox').jqxListBox('getSelectedIndex');
var items = $("#listbox").jqxListBox('source');
items.splice(indexSelected, 1);
$("#listbox").jqxListBox('source', items);
});
$("#up").jqxButton({disabled: true, width: '8%'});
$("#down").jqxButton({disabled: true, width: '8%'});
$('#up').on('click', function() {
var indexSelected = $('#listbox').jqxListBox('getSelectedIndex');
var items = $("#listbox").jqxListBox('source');
items.move(indexSelected, indexSelected - 1);
$("#listbox").jqxListBox('source', items);
$("#listbox").jqxListBox('selectIndex', indexSelected - 1);
});
$('#down').on('click', function() {
var indexSelected = $('#listbox').jqxListBox('getSelectedIndex');
var items = $("#listbox").jqxListBox('source');
items.move(indexSelected, indexSelected + 1);
$("#listbox").jqxListBox('source', items);
$("#listbox").jqxListBox('selectIndex', indexSelected + 1);
});
var dataAdapter = $('#listbox').jqxListBox('source');
if (dataAdapter === undefined)
{
source = {
localdata: [],
datafields: [
{name: 'id_tipo_ingredienti'},
{name: 'id_tipo_quantita'},
{name: 'nome_ingrediente'},
{name: 'note'},
{name: 'posizione'},
{name: 'quantita'},
{name: 'unita'}
],
datatype: "array"
};
dataAdapter = new $.jqx.dataAdapter(source);
}
$('#listbox').jqxListBox({
//allowDrag: true,
source: dataAdapter, itemHeight: 30, height: '90%', width: '100%', theme: 'arctic',
renderer: function(index, label, value) {
var datarecord = this.source[index];
if (datarecord)
{
var div = '';
if (datarecord.id_tipo_ingredienti === "22")
{
div = '<div><b>' + datarecord.nome_ingrediente + '</b>: <i>' + datarecord.note + '</i></div>';
}
else
{
div = '<div><b>' + datarecord.nome_ingrediente + '</b>: ' + datarecord.quantita + ' ' + datarecord.unita + ' <i>' + datarecord.note + '</i></div>';
}
return div;
}
return "";
},
dragEnd: function(dragItem, dropItem) {
this.source.move(dragItem.index, dropItem.index);
return true;
}
});
$('#listbox').on('select', function(event) {
var args = event.args;
if (args) {
$("#remove").jqxButton({disabled: false});
if (args.index === 0)
{
$("#up").jqxButton({disabled: true});
$("#down").jqxButton({disabled: false});
}
else if (args.index === event.owner.source.length - 1)
{
$("#up").jqxButton({disabled: false});
$("#down").jqxButton({disabled: true});
}
else
{
$("#up").jqxButton({disabled: false});
$("#down").jqxButton({disabled: false});
}
}
});
$('#listbox').on('unselect', function(event) {
var args = event.args;
if (args) {
$("#remove").jqxButton({disabled: true});
}
});
}
else if (tab === 2)
{
var text = $('#procedimento').val();
$('#procedimento').jqxEditor({width: '100%', height: "100%"});
if (text)
$('#procedimento').jqxEditor('val', text);
}
}
});
$("#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": 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");
});
$("#Cancel").jqxButton({width: '48%', height: 40});
}
});
//
// $('#popupWindow').on('resized', function (event) {
// $('#procedimento').jqxEditor({width: '100%', height: 380});
// });
this.addIngrDlg = new AddIngrDlg();
this.$el.find("#content").append(this.addIngrDlg.$el);
this.addIngrDlg.render();
this.addIngrDlg.addBtnFn = function(item) {
var items = $("#listbox").jqxListBox('source');
items.push(item);
$("#listbox").jqxListBox('source', items);
};
return this;
}
});
return EditRicetteView;
});
@@ -0,0 +1,52 @@
<div id="content">
<div id="popupWindow" style="overflow: hidden; display: none;">
<div>Edit</div>
<div>
<input type="hidden" id="ricettaID" />
<div id='jqxTabs'>
<ul>
<li style="margin-left: 30px;">Informazioni Generali</li>
<li>Ingredienti</li>
<li>Procedimento</li>
</ul>
<div>
<table>
<tr>
<td align="right">Categoria</td>
<td align="left"><div id="categoria"></div></td>
</tr>
<tr>
<td align="right">Titolo:</td>
<td align="left"><input id="titolo" /></td>
</tr>
<tr>
<td align="right">Livello di Difficoltà:</td>
<td align="left"><div id='lvlDiff'></div></td>
</tr>
<tr>
<td align="right">Autore:</td>
<td align="left"><input id="autore" /></td>
</tr>
<tr>
<td align="right">Link Fonte:</td>
<td align="left"><input id="linkFonte" /></td>
</tr>
<tr>
<td align="right">Link Video YouTube:</td>
<td align="left"><input id="linkYouTube" /></td>
</tr>
</table>
</div>
<div>
<input id="add" style="margin-right: 1%;" type="button" value="Aggiungi Ingrediente"/>
<input id="up" style="margin-right: 1%;" type="button" value="Up"/>
<input id="down" style="margin-right: 1%;" type="button" value="Down"/>
<input id="remove" type="button" value="Cancella Ingrediente"/>
<div style="border: none;" id="listbox"></div>
</div>
<div><textarea id="procedimento"></textarea></div>
</div>
<input style="margin-right: 5px;" type="button" id="Save" value="Save" /><input id="Cancel" type="button" value="Cancel" />
</div>
</div>
</div>
+73
View File
@@ -0,0 +1,73 @@
define(['jquery', 'underscore', 'backbone', 'text!modules/home/homeViewTemplate.html',
'modules/base/baseView', 'modules/ricette/ricette', 'modules/editricetta/editricetta', 'modules/photos/photos',
'jqxbuttons', 'jqxmenu', 'jqxwindow'],
function($, _, Backbone, homeViewTemplate, BaseView, RicetteView, EditRicettaView, PhotosView) {
var HomeView = BaseView.extend({
//initialize template
template: _.template(homeViewTemplate),
initialize: function() {
HomeView.__super__.initialize.call(this);
//this.header.title = "pippo";
},
addRicetta: function() {
//e.preventDefault();
var editRicetteView = new EditRicettaView();
editRicetteView.render();
$('body').append(editRicetteView.$el);
editRicetteView.openRicetta();
},
modifyRicetta: function() {
//e.preventDefault();
var ricetteView = new RicetteView();
ricetteView.render();
$('body').append(ricetteView.$el);
},
photosView: function(){
var photosView = new PhotosView();
photosView.render();
$('body').append(photosView.$el);
},
clickMenu: function(event) {
var item = $(event.target);
//var clickedItem = event.args;
if(item[0].id === "addRicetta" ||
item[0].lastChild.id === "addRicetta")
{
event.data.scope.addRicetta();
}
else if(item[0].id === "modifyRicetta" ||
item[0].lastChild.id === "modifyRicetta")
{
event.data.scope.modifyRicetta();
}
else if(item[0].id === "viewPhotos" ||
item[0].lastChild.id === "viewPhotos")
{
event.data.scope.photosView();
}
},
//render the content into div of view
render: function() {
//this.header.title = "pippo";
HomeView.__super__.render.call(this);
if ($('#jqxMenu').length === 0)
{
this.$el.append(this.template());
this.$el.find("#jqxMenu").jqxMenu({
width: '60%',
height: '30px'
});
this.$el.find('#jqxMenu').on('itemclick', { scope: this }, this.clickMenu);
}
//$("#homeBtn").addClass("ui-btn-active");
//return to enable chained calls
return this;
}
});
return HomeView;
});
+31
View File
@@ -0,0 +1,31 @@
<div id="contentMenu">
<div id='jqxMenu'>
<ul>
<li>Gestione Ricette
<ul style='width: 250px;'>
<li><a id="addRicetta" href="#">Aggiungi</a></li>
<li><a id="modifyRicetta" href="#">Modifica</a></li>
</ul>
</li>
<!--
<li>Ingredienti
<ul style='width: 250px;'>
<li><a id="addIngredienti" href="#">Aggiungi</a></li>
<li><a id="modifyIngredienti" href="#">Modifica</a></li>
</ul>
</li>
<li>Gestione Foto
<ul style='width: 250px;'>
<li><a id="viewPhotos" href="#">Visualizza</a></li>
<!--<li><a id="publishPhoto" href="#">Approva</a></li>
<li><a id="deletePhoto" href="#">Cancella</a></li>
</ul>
</li>
<li>Gestione Profili
<ul style='width: 250px;'>
<li><a id="viewProfiles" href="#">Visualizza</a></li>
</ul>
</li>-->
</ul>
</div>
</div>
+147
View File
@@ -0,0 +1,147 @@
define(['jquery', 'underscore', 'backbone', 'text!modules/photos/photosViewTemplate.html', 'modules/base/baseView',
'controls/window/window', 'jqxdata', 'jqxdropdownlist',
'jqxgrid', 'jqxgrid_selection', 'jqxgrid_columnsresize', 'jqxgrid_filter'],
function($, _, Backbone, photosViewTemplate, BaseView, Window) {
var PhotosView = BaseView.extend({
dataAdapter: undefined,
//initialize template
template: _.template(photosViewTemplate),
initialize: function() {
PhotosView.__super__.initialize.call(this);
//this.header.title = "pippo";
},
checkPhotos: function(row){
var dataRecord = $("#gridPhotos").jqxGrid('getrowdata', row);
},
//render the content into div of view
render: function() {
//this.header.title = "pippo";
PhotosView.__super__.render.call(this);
var self = this;
var window = new Window({
title: "Foto",
width: "850px",
resizable: false,
height: "510px",
content: "<p><h3>Ricette</h3><div id=\"gridRicette\"></div><h3>Foto</h3><div id=\"gridPhotos\"></div></p>",
initContentFn: function() {
// prepare the data
self.dataAdapter = new $.jqx.dataAdapter({
datatype: "jsonp",
datafields: [
{name: 'ricetta_id', type: 'int'},
{name: 'titolo', type: 'string'},
{name: 'autore', type: 'string'},
{name: 'num_img', type: 'int'},
{name: 'num_img_pub', type: 'int'},
{name: 'all_published', type: 'bool'}
],
id: 'ricetta_id',
url: myManifest.Settings.DefaultURL + "/backend/photos",
data: {
}
});
$("#gridRicette").jqxGrid({
width: "100%",
height: "200px",
source: self.dataAdapter,
filterable: true,
autoshowfiltericon: true,
columns: [
{text: 'Titolo', dataField: 'titolo', width: "400px"},
{text: 'Inviate', dataField: 'num_img', width: "65px"},
{text: 'All Published', editable: false, dataField: 'all_published', width: "70px",
cellsrenderer: function(index, datafield, value, defaultvalue, column, rowdata) {
var total = (parseFloat(rowdata.num_img) === parseFloat(rowdata.num_img_pub));
return "<div style='margin: 4px;' class='jqx-center-align'>" + total + "</div>";
}
}
]
});
var photoFields = [
{name: 'id_photo', type: 'int'},
{name: 'type_format', type: 'string'},
{name: 'from_profile_id', type: 'string'},
{name: 'uploaded_date', type: 'datetime'},
{name: 'profile_name', type: 'string'},
{name: 'published', type: 'bool'}
];
var photoAdapter = new $.jqx.dataAdapter({
datatype: "jsonp",
datafields: photoFields,
id: 'id_photo',
url: myManifest.Settings.DefaultURL + "/backend/ricetta/0/photos",
data: {
}
});
$("#gridPhotos").jqxGrid({
width: "100%",
height: "150px",
source: photoAdapter,
rowsheight: 100,
//filterable: true,
autoshowfiltericon: true,
columns: [
{text: 'Autore', dataField: 'profile_name', width: "170px"},
{text: 'Image', dataField: 'image', width: "210px",
cellsrenderer: function(index, datafield, value, defaultvalue, column, rowdata) {
return '<img style="margin-left: 5px;width: 200px;" src="' + myManifest.Settings.DefaultURL + '/api/photos/thumbnail/' + rowdata.id_photo + '"/>';
}
},
{text: 'Published', editable: false, dataField: 'published', width: "70px",
cellsrenderer: function(index, datafield, value, defaultvalue, column, rowdata) {
var valueBool = rowdata.published;
return "<div style='margin: 4px;' class='jqx-center-align'>" + valueBool + "</div>";
}
},
{text: '', datafield: 'FullView', columntype: 'button', width: '10%',
cellsrenderer: function() {
return "View Full";
},
buttonclick: function(row) {
}
},
{text: '', datafield: 'Publish', columntype: 'button', width: '10%',
cellsrenderer: function() {
return "Publish";
},
buttonclick: function(row) {
if(row.published === false)
{}
}
}
]
});
$('#gridRicette').on('rowselect', function(event)
{
var ricetta_id = event.args.row.ricetta_id;
var photoAdapter = new $.jqx.dataAdapter({
datatype: "jsonp",
datafields: photoFields,
id: 'id_photo',
url: myManifest.Settings.DefaultURL + "/backend/ricetta/" + ricetta_id + "/photos",
data: {
}
});
$("#gridPhotos").jqxGrid({ source: photoAdapter });
});
}
});
window.id = "photos";
this.$el.append(this.template());
this.$el.find("#content").append(window.$el);
window.render();
return this;
}
});
return PhotosView;
});
@@ -0,0 +1,2 @@
<div id="content">
</div>
+134
View File
@@ -0,0 +1,134 @@
define(['jquery', 'underscore', 'backbone', 'text!modules/ricette/ricetteViewTemplate.html', 'modules/base/baseView',
'controls/window/window', 'modules/editricetta/editricetta', 'jqxdata', 'jqxdropdownlist',
'jqxgrid', 'jqxgrid_selection', 'jqxgrid_columnsresize', 'jqxgrid_filter'],
function($, _, Backbone, ricetteViewTemplate, BaseView, Window, EditRicetta) {
var RicetteView = BaseView.extend({
dataAdapter: undefined,
//initialize template
template: _.template(ricetteViewTemplate),
editorRicetta: null,
initialize: function() {
RicetteView.__super__.initialize.call(this);
//this.header.title = "pippo";
},
fillGrid: function(event)
{
var self = event.data.scope;
if (event.args) {
var item = event.args.item;
if (item) {
self.dataAdapter._source.url = myManifest.Settings.DefaultURL + "/backend/categoryitems/" + item.value;
self.dataAdapter.dataBind();
$("#jqxgrid").jqxGrid('updatebounddata');
}
}
},
openRicetta: function(row) {
var editrow = row;
var dataRecord = $("#jqxgrid").jqxGrid('getrowdata', editrow);
this.editorRicetta.openRicetta(dataRecord.ricetta_id);
},
//render the content into div of view
render: function() {
//this.header.title = "pippo";
RicetteView.__super__.render.call(this);
var self = this;
var window = new Window({
title: "Ricette",
width: "850px",
resizable: true,
height: "510px",
maxHeight: 1000,
maxWidth: 1000,
content: "<p><div id=\"categoriaCmb\"></div></p>\n\
<p><div id=\"jqxgrid\"></div></p>",
initContentFn: function() {
var source =
{
datatype: "jsonp",
datafields: [
{name: 'category_id'},
{name: 'name'}
],
url: myManifest.Settings.DefaultURL + "/backend/categories",
data: {
}
};
var dataAdapter = new $.jqx.dataAdapter(source);
$("#categoriaCmb").jqxDropDownList(
{
width: 200,
height: 25,
source: dataAdapter,
selectedIndex: 0,
displayMember: "name",
valueMember: "category_id"
});
$("#categoriaCmb").on('select', {scope: self}, self.fillGrid);
// prepare the data
self.dataAdapter = new $.jqx.dataAdapter({
datatype: "jsonp",
datafields: [
{name: 'ricetta_id', type: 'int'},
{name: 'titolo', type: 'string'},
{name: 'autore', type: 'string'}
],
id: 'ricetta_id',
url: myManifest.Settings.DefaultURL + "/backend/categoryitems/0"
});
$("#jqxgrid").jqxGrid({
width: "100%",
height: "87%",
source: self.dataAdapter,
filterable: true,
autoshowfiltericon: true,
columns: [
{text: 'Titolo', dataField: 'titolo', width: "58%",
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: "34%",
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: '7%',
cellsrenderer: function() {
return "Edit";
},
buttonclick: function(row) {
self.openRicetta(row);
}
}
]
});
$('#jqxgrid').on('rowdoubleclick', function(event)
{
var args = event.args;
var row = args.rowindex;
self.openRicetta(row);
});
}
});
window.id = "ricette";
this.$el.append(this.template());
this.$el.find("#content").append(window.$el);
window.render();
this.editorRicetta = new EditRicetta();
this.$el.find("#content").append(this.editorRicetta.$el);
this.editorRicetta.render();
return this;
}
});
return RicetteView;
});
@@ -0,0 +1,2 @@
<div id="content">
</div>