Fixed all known bugs; Modified the menu to hide; Fixed the tables to scroll with a fixed header.
This commit is contained in:
@@ -15,7 +15,7 @@ Template.SalesSheets.onCreated(function() {
|
||||
Template.SalesSheets.onDestroyed(function() {
|
||||
// Reset the view's session variables used for navigation.
|
||||
Session.set(PREFIX + "currentFormName", undefined);
|
||||
Session.set(PREFIX + "tab", undefined);
|
||||
Session.set(PREFIX + "activeTemplateName", undefined);
|
||||
});
|
||||
|
||||
//******************************************************************
|
||||
@@ -24,10 +24,11 @@ Template.SalesSheets.onDestroyed(function() {
|
||||
Template.SalesSheetsMain.onCreated(function() {
|
||||
//Save the previous session state - whether we are editing the selected sheet.
|
||||
//The name of the currently active page tab. This will either be the SalesSheetForm or the SalesSheetEditor.
|
||||
if(!Session.get(PREFIX + "tab")) Session.set(PREFIX + "tab", "SalesSheetForm");
|
||||
if(!Session.get(PREFIX + 'selectedSheet')) {
|
||||
Session.set(PREFIX + 'selectedSheet', Meteor.collections.SalesSheets.findOne({}, {sort: {name: 1}}));
|
||||
}
|
||||
if(!Session.get(PREFIX + "activeTemplateName")) Session.set(PREFIX + "activeTemplateName", "SalesSheetForm");
|
||||
|
||||
this.sheets = Meteor.collections.SalesSheets.find({}, {sort: {name: 1}});
|
||||
let sheetArray = this.sheets.fetch();
|
||||
Session.set(PREFIX + 'selectedSheet', sheetArray.length > 0 ? sheetArray[0] : null);
|
||||
});
|
||||
Template.SalesSheetsMain.helpers({
|
||||
sheets: function() {
|
||||
@@ -36,35 +37,27 @@ Template.SalesSheetsMain.helpers({
|
||||
//if(sheets && sheets.length > 0) sheets[0].isFirst = true;
|
||||
//
|
||||
//return sheets;
|
||||
return Meteor.collections.SalesSheets.find({}, {sort: {name: 1}});
|
||||
return Template.instance().sheets;
|
||||
},
|
||||
sheetsSelectIsSelected: function(sheet, isFirst) {
|
||||
isSheetSelected: function() { // Determines if the passed sheet is the selected sheet and returns either "selected" or "".
|
||||
let selectedSheet = Session.get(PREFIX + "selectedSheet");
|
||||
|
||||
if(!selectedSheet && isFirst) Session.set(PREFIX + "selectedSheet", selectedSheet = sheet);
|
||||
|
||||
return selectedSheet == sheet ? "selected" : "";
|
||||
return selectedSheet == this ? "selected" : "";
|
||||
},
|
||||
disableButtons: function() {
|
||||
//Disable the edit & delete functionality if nothing is selected.
|
||||
disableButtons: function() { // Disable the edit & delete functionality if nothing is selected.
|
||||
return !Session.get(PREFIX + "selectedSheet");
|
||||
},
|
||||
selected: function() {
|
||||
//Get whether the current sheet is selected and return the string for use in the option tag.
|
||||
//return this.isSelected ? "selected" : "";
|
||||
return this._id == Session.get(PREFIX + 'selectedSheet')._id;
|
||||
activeTemplateName: function() { // The name of the template actively being shown to the user in the content area.
|
||||
return Session.get(PREFIX + "activeTemplateName");
|
||||
},
|
||||
tab: function() {
|
||||
return Session.get(PREFIX + "tab");
|
||||
selectedSheetId: function() { // Gets the ID of the sheet currently selected. This is passed to the template being actively show to the user.
|
||||
return Session.get(PREFIX + "selectedSheet") ? Session.get(PREFIX + "selectedSheet")._id : null;
|
||||
},
|
||||
tabData: function() {
|
||||
return Session.get(PREFIX + "selectedSheet")._id;
|
||||
},
|
||||
isSheetSelected: function() {
|
||||
hasSelectedSheet: function() { // Determines whether any sheet has been selected.
|
||||
return Session.get(PREFIX + "selectedSheet");
|
||||
},
|
||||
isEditingSheet: function() {
|
||||
return Session.get(PREFIX + "tab") == "SalesSheetEditor";
|
||||
return Session.get(PREFIX + "activeTemplateName") == "SalesSheetEditor";
|
||||
}
|
||||
});
|
||||
Template.SalesSheetsMain.events({
|
||||
@@ -74,16 +67,16 @@ Template.SalesSheetsMain.events({
|
||||
|
||||
Session.set(PREFIX + "selectedSheet", selected);
|
||||
// Reset the editor button & the displayed tab.
|
||||
Session.set(PREFIX + "tab", "SalesSheetForm");
|
||||
Session.set(PREFIX + "activeTemplateName", "SalesSheetForm");
|
||||
},
|
||||
'click .editSheet': function(event, template) {
|
||||
if(!$(event.target).hasClass("selected")) {
|
||||
// Display the editor for the sheet.
|
||||
Session.set(PREFIX + "tab", "SalesSheetEditor");
|
||||
Session.set(PREFIX + "activeTemplateName", "SalesSheetEditor");
|
||||
}
|
||||
else {
|
||||
// Remove the sheet editor and show the form to fill out the sheet.
|
||||
Session.set(PREFIX + "tab", "SalesSheetForm");
|
||||
Session.set(PREFIX + "activeTemplateName", "SalesSheetForm");
|
||||
// Reset the editor session variables.
|
||||
Session.set(PREFIX + "currentFormName", undefined);
|
||||
}
|
||||
@@ -137,7 +130,7 @@ Template.SalesSheetsMain.events({
|
||||
template.$('select[name="sheetSelection"]').val(id);
|
||||
Session.set(PREFIX + "selectedSheet", selected);
|
||||
//Display the editor tab.
|
||||
Session.set(PREFIX + "tab", "SalesSheetEditor");
|
||||
Session.set(PREFIX + "activeTemplateName", "SalesSheetEditor");
|
||||
clearInterval(interval);
|
||||
}
|
||||
else count++;
|
||||
|
||||
Reference in New Issue
Block a user