partkeepr

fork of partkeepr
git clone https://git.e1e0.net/partkeepr.git
Log | Files | Refs | Submodules | README | LICENSE

commit d20ceba18242bb780a2e2e12c6020edf26ebd286
parent 5c0f723fcf9379f377ba9102939060cc225f1109
Author: Felicitus <felicitus@felicitus.org>
Date:   Mon,  2 Nov 2015 19:59:41 +0100

Refactored menu system

Diffstat:
Msrc/PartKeepr/FrontendBundle/Controller/IndexController.php | 2++
Msrc/PartKeepr/FrontendBundle/Resources/public/js/Components/Distributor/DistributorEditorComponent.js | 11++++++++---
Msrc/PartKeepr/FrontendBundle/Resources/public/js/Components/Footprint/FootprintEditorComponent.js | 9+++++++--
Msrc/PartKeepr/FrontendBundle/Resources/public/js/Components/Manufacturer/ManufacturerEditorComponent.js | 44++++++++++++++++++++++++++------------------
Msrc/PartKeepr/FrontendBundle/Resources/public/js/Components/MenuBar.js | 411+++++++++++++++++--------------------------------------------------------------
Msrc/PartKeepr/FrontendBundle/Resources/public/js/Components/PartMeasurementUnit/PartMeasurementUnitEditorComponent.js | 11++++++++---
Msrc/PartKeepr/FrontendBundle/Resources/public/js/Components/Project/ProjectEditorComponent.js | 6++++++
Msrc/PartKeepr/FrontendBundle/Resources/public/js/Components/Project/ProjectReport.js | 6++++++
Dsrc/PartKeepr/FrontendBundle/Resources/public/js/Components/Statistics/CurrentStatisticsPanel.js | 93-------------------------------------------------------------------------------
Msrc/PartKeepr/FrontendBundle/Resources/public/js/Components/Statistics/StatisticsChart.js | 3+--
Msrc/PartKeepr/FrontendBundle/Resources/public/js/Components/Statistics/StatisticsChartPanel.js | 9+++++++--
Asrc/PartKeepr/FrontendBundle/Resources/public/js/Components/Statistics/SummaryStatisticsPanel.js | 98+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Msrc/PartKeepr/FrontendBundle/Resources/public/js/Components/StockReport/StockHistoryGrid.js | 73+++++++++++++++++++++++++++++++++++++++++--------------------------------
Msrc/PartKeepr/FrontendBundle/Resources/public/js/Components/StorageLocation/StorageLocationEditorComponent.js | 11++++++++---
Msrc/PartKeepr/FrontendBundle/Resources/public/js/Components/SystemInformation/SystemInformationGrid.js | 6++++++
Msrc/PartKeepr/FrontendBundle/Resources/public/js/Components/SystemNotice/SystemNoticeEditorComponent.js | 6++++++
Msrc/PartKeepr/FrontendBundle/Resources/public/js/Components/Unit/UnitEditorComponent.js | 11++++++++---
Msrc/PartKeepr/FrontendBundle/Resources/public/js/Components/User/UserEditorComponent.js | 6++++++
Msrc/PartKeepr/FrontendBundle/Resources/public/js/Components/User/UserPreferences.js | 42++++++++++++++++++++++++++++--------------
Msrc/PartKeepr/FrontendBundle/Resources/public/js/PartKeepr.js | 24++++++++++++++++++++++++
Msrc/PartKeepr/FrontendBundle/Resources/views/index.html.twig | 2+-
21 files changed, 384 insertions(+), 500 deletions(-)

diff --git a/src/PartKeepr/FrontendBundle/Controller/IndexController.php b/src/PartKeepr/FrontendBundle/Controller/IndexController.php @@ -60,6 +60,8 @@ class IndexController extends Controller $aParameters["motd"] = Configuration::getOption("partkeepr.frontend.motd"); } + $aParameters["max_users"] = $this->getParameter("max_users"); + $aParameters["authentication_provider"] = $this->getParameter("partkeepr.authentication_provider"); $aParameters["tip_of_the_day_uri"] = $this->getParameter("partkeepr.tip_of_the_day_uri"); diff --git a/src/PartKeepr/FrontendBundle/Resources/public/js/Components/Distributor/DistributorEditorComponent.js b/src/PartKeepr/FrontendBundle/Resources/public/js/Components/Distributor/DistributorEditorComponent.js @@ -14,5 +14,11 @@ Ext.define('PartKeepr.DistributorEditorComponent', { }); this.callParent(); - } -});- \ No newline at end of file + }, + statics: { + iconCls: 'web-icon lorry', + title: i18n('Distributors'), + closable: true, + menuPath: [{text: i18n("Edit")}] + } +}); diff --git a/src/PartKeepr/FrontendBundle/Resources/public/js/Components/Footprint/FootprintEditorComponent.js b/src/PartKeepr/FrontendBundle/Resources/public/js/Components/Footprint/FootprintEditorComponent.js @@ -20,5 +20,11 @@ Ext.define('PartKeepr.FootprintEditorComponent', { }); this.callParent(); + }, + statics: { + iconCls: 'fugue-icon fingerprint', + title: i18n('Footprints'), + closable: true, + menuPath: [{ text: i18n("Edit")}] } -});- \ No newline at end of file +}); diff --git a/src/PartKeepr/FrontendBundle/Resources/public/js/Components/Manufacturer/ManufacturerEditorComponent.js b/src/PartKeepr/FrontendBundle/Resources/public/js/Components/Manufacturer/ManufacturerEditorComponent.js @@ -1,18 +1,27 @@ Ext.define('PartKeepr.ManufacturerEditorComponent', { - extend: 'PartKeepr.EditorComponent', - alias: 'widget.ManufacturerEditorComponent', - navigationClass: 'PartKeepr.ManufacturerGrid', - editorClass: 'PartKeepr.ManufacturerEditor', - newItemText: i18n("New Manufacturer"), - model: 'PartKeepr.ManufacturerBundle.Entity.Manufacturer', - initComponent: function () { - this.createStore({ - sorters: [{ - property: 'name', - direction:'ASC' - }] - }); - - this.callParent(); - } -});- \ No newline at end of file + extend: 'PartKeepr.EditorComponent', + alias: 'widget.ManufacturerEditorComponent', + navigationClass: 'PartKeepr.ManufacturerGrid', + editorClass: 'PartKeepr.ManufacturerEditor', + newItemText: i18n("New Manufacturer"), + model: 'PartKeepr.ManufacturerBundle.Entity.Manufacturer', + initComponent: function () + { + this.createStore({ + sorters: [ + { + property: 'name', + direction: 'ASC' + } + ] + }); + + this.callParent(); + }, + statics: { + iconCls: 'web-icon building', + title: i18n('Projects'), + closable: true, + menuPath: [{text: i18n("Edit")}] + } +}); diff --git a/src/PartKeepr/FrontendBundle/Resources/public/js/Components/MenuBar.js b/src/PartKeepr/FrontendBundle/Resources/public/js/Components/MenuBar.js @@ -1,326 +1,89 @@ Ext.define('PartKeepr.MenuBar', { - extend: 'Ext.toolbar.Toolbar', - initComponent: function () { - this.ui = "mainmenu"; - - // @todo this is an ugly list of configurations. Refactor this in a cleaner way. - - this.editMenu = Ext.create('Ext.menu.Menu', { - items: [{ - text: i18n('Projects'), - iconCls: 'fugue-icon drill', - handler: this.editProjects - }, - { - text: i18n('Footprints'), - iconCls: 'fugue-icon fingerprint', - handler: this.editFootprints - },{ - text: i18n('Manufacturers'), - iconCls: 'web-icon building', - handler: this.editManufacturers - },{ - text: i18n('Storage Locations'), - iconCls: 'fugue-icon wooden-box', - handler: this.editStorageLocations - },{ - text: i18n('Distributors'), - iconCls: 'web-icon lorry', - handler: this.editDistributors - },{ - text: i18n('Users'), - id: 'edit-users', - handler: this.editUsers, - iconCls: "web-icon user" - },{ - text: i18n('Part Measurement Units'), - handler: this.editPartUnits, - iconCls: "fugue-icon ruler" - },{ - text: i18n("Units"), - handler: this.editUnits, - iconCls: 'partkeepr-icon unit' - }] - }); - - this.viewMenu = Ext.create('Ext.menu.Menu', { - items: [{ - text: i18n("Statistics"), - iconCls: 'web-icon chart_bar', - menu: [ - { - text: i18n("Summary"), - handler: this.showStatisticsSummary, - iconCls: 'web-icon chart_bar' - },{ - text: i18n("Chart"), - handler: this.showStatisticsChart, - iconCls: 'web-icon chart_bar' - }] - }, - { - text: i18n("System Information"), - handler: this.showSystemInformation, - iconCls: 'fugue-icon system-monitor ' - },{ - text: i18n("Project Reports"), - handler: this.showProjectReports, - iconCls: 'fugue-icon drill' - },{ - text: i18n("System Notices"), - handler: this.showSystemNotices, - iconCls: 'fugue-icon service-bell' - },{ - text: i18n("Stock History"), - handler: this.showStockHistory, - iconCls: 'fugue-icon notebook' - },{ - text: i18n("Print and Labeling"), - glyph: 0xf02f, - menu: [ - { - text: i18n("Storage Locations"), - handler: this.showPrintStorageLocations - },{ - text : i18n("Edit Label Layout"), - handler : this.editPrintingPageBasicLayout - },{ - text : i18n("Edit Configuration"), - handler : this.editPrintingJobConfiguration - }] - }] - }); - - this.systemMenu = Ext.create('Ext.menu.Menu', { - items: [ - { - text: i18n('Disconnect'), - iconCls: 'web-icon disconnect', - handler: this.disconnect - },{ - text: i18n("User Preferences"), - iconCls: 'fugue-icon gear', - handler: this.showUserPreferences - } - ] - }); - - this.items = [{ - text: i18n("System"), - menu: this.systemMenu - },{ - text: i18n('Edit'), - menu: this.editMenu - },{ - text: i18n('View'), - menu: this.viewMenu - }, - '->', - { - xtype: 'tbtext', - cls: 'partkeepr-logo', - text: 'PartKeepr' - }]; - - - - this.callParent(); - }, - showUserPreferences: function () { - var j = new PartKeepr.UserPreferencePanel({ - iconCls: 'fugue-icon gear', - closable: true - }); - - PartKeepr.getApplication().addItem(j); - j.show(); - }, - disconnect: function () { - PartKeepr.getApplication().logout(); - }, - /** - * Shows the system information window - */ - showSystemInformation: function () { - var j = Ext.create("PartKeepr.SystemInformationGrid", { - title: i18n("System Information"), - iconCls: 'fugue-icon system-monitor', - closable: true, - padding: "5 5 5 5" - }); - - - PartKeepr.getApplication().addItem(j); - j.show(); - }, - showStatisticsSummary: function () { - var j = Ext.create("PartKeepr.CurrentStatisticsPanel", { - iconCls: 'web-icon chart-bar', - closable: true - }); - - - PartKeepr.getApplication().addItem(j); - j.show(); - }, - showStatisticsChart: function () { - var j = Ext.create("PartKeepr.StatisticsChartPanel", { - iconCls: 'web-icon chart-bar', - closable: true - }); - - - PartKeepr.getApplication().addItem(j); - j.show(); - }, - editStorageLocations: function () { - var j = Ext.create("PartKeepr.StorageLocationEditorComponent", { - title: i18n("Storage Locations"), - iconCls: 'fugue-icon wooden-box', - closable: true - }); - - PartKeepr.getApplication().addItem(j); - j.show(); - }, - editUnits: function () { - var j = Ext.create("PartKeepr.UnitEditorComponent", { - title: i18n("Units"), - iconCls: 'partkeepr-icon unit', - closable: true - }); - - PartKeepr.getApplication().addItem(j); - j.show(); - }, - editManufacturers: function () { - var j = Ext.create("PartKeepr.ManufacturerEditorComponent", { - title: i18n("Manufacturers"), - iconCls: 'web-icon building', - closable: true - }); - - PartKeepr.getApplication().addItem(j); - j.show(); - }, - editFootprints: function () { - var j = Ext.create("PartKeepr.FootprintEditorComponent", { - title: i18n("Footprints"), - iconCls: 'fugue-icon fingerprint', - closable: true - }); - - PartKeepr.getApplication().addItem(j); - j.show(); - }, - editDistributors: function () { - var j = Ext.create("PartKeepr.DistributorEditorComponent", { - title: i18n("Distributors"), - iconCls: 'web-icon lorry', - closable: true - }); - - PartKeepr.getApplication().addItem(j); - j.show(); - }, - editUsers: function () { - var j = Ext.create("PartKeepr.UserEditorComponent", { - title: i18n("Users"), - iconCls: 'web-icon user', - closable: true - }); - - PartKeepr.getApplication().addItem(j); - j.show(); - }, - editPartUnits: function () { - var j = Ext.create("PartKeepr.PartMeasurementUnitEditorComponent", { - title: i18n("Part Measurement Units"), - iconCls: "fugue-icon ruler", - closable: true - }); - - PartKeepr.getApplication().addItem(j); - j.show(); - }, - editProjects: function () { - var j = Ext.create("PartKeepr.ProjectEditorComponent", { - title: i18n("Projects"), - iconCls: 'fugue-icon drill', - closable: true - }); - - PartKeepr.getApplication().addItem(j); - j.show(); - }, - showProjectReports: function () { - var j = Ext.create("PartKeepr.ProjectReportView", { - title: i18n("Project Reports"), - iconCls: 'fugue-icon drill', - closable: true - }); - - PartKeepr.getApplication().addItem(j); - j.show(); - }, - showSystemNotices: function () { - var j = Ext.create("PartKeepr.SystemNoticeEditorComponent", { - title: i18n("System Notices"), - iconCls: 'web-icon bell', - closable: true - }); - - PartKeepr.getApplication().addItem(j); - j.show(); - }, - showStockHistory: function () { - var j = Ext.create("PartKeepr.StockHistoryGrid", { - title: i18n("Stock History"), - iconCls: 'fugue-icon notebook', - closable: true - }); - - PartKeepr.getApplication().addItem(j); - j.show(); - }, - displayComponent: function (component) { - var j = Ext.create(component.type, { - title: component.title, - iconCls: component.iconCls, - closable: component.closable - }); - - PartKeepr.getApplication().addItem(j); - j.show(); - }, - showPrintStorageLocations: function () { - var j = Ext.create("PartKeepr.PrintStorageLocations", { - title: i18n("Printing and Labeling: Storage Locations"), - iconCls: 'web-icon drill', - closable: true - }); - - PartKeepr.getApplication().addItem(j); - j.show(); - }, - editPrintingPageBasicLayout: function () { - var j = Ext.create("PartKeepr.Printing.PageBasicLayoutEditorComponent", { - title: i18n("Labeling Layout"), - iconCls: 'web-icon drill', - closable: true - }); - - PartKeepr.getApplication().addItem(j); - j.show(); - }, - editPrintingJobConfiguration: function () { - var j = Ext.create("PartKeepr.Printing.PrintingJobConfigurationEditorComponent", { - title: i18n("Printing Configuration"), - iconCls: 'web-icon drill', - closable: true - }); - - PartKeepr.getApplication().addItem(j); - j.show(); - } + extend: 'Ext.toolbar.Toolbar', + alias: "widget.MenuBar", + menu: { + text: "Root", + menu: [] + }, + + createMenu: function (target, menuPath, root) { + var item = menuPath.shift(); + + if (item === undefined) { + var newItem = { text: target.title, iconCls: target.iconCls, target: target }; + + root.menu.push(newItem); + return root; + } + + var foundItem = false; + + for (var i=0;i<root.menu.length;i++) { + if (root.menu[i].text == item.text) { + Ext.applyIf(root.menu[i], item); + foundItem = i; + } + } + + if (foundItem === false) { + var newItem = { menu: []}; + + Ext.applyIf(newItem, item); + + var data = this.createMenu(target, menuPath, newItem); + root.menu.push(data); + } else { + this.createMenu(target, menuPath, root.menu[foundItem]); + + } + + return root; + }, + initComponent: function () + { + var target, menus, menuItemIterator, menuPathIterator; + + this.ui = "mainmenu"; + + var menuItems = [ + // System Menu + "PartKeepr.UserPreferencePanel", + + // Edit Menu + "PartKeepr.ProjectEditorComponent", + "PartKeepr.FootprintEditorComponent", + "PartKeepr.ManufacturerEditorComponent", + "PartKeepr.StorageLocationEditorComponent", + "PartKeepr.DistributorEditorComponent", + "PartKeepr.UserEditorComponent", + "PartKeepr.PartMeasurementUnitEditorComponent", + "PartKeepr.UnitEditorComponent", + + // View Menu + "PartKeepr.SummaryStatisticsPanel", + "PartKeepr.StatisticsChartPanel", + "PartKeepr.SystemInformationGrid", + "PartKeepr.ProjectReportView", + "PartKeepr.SystemNoticeEditorComponent", + "PartKeepr.StockHistoryGrid" + ]; + + + for (menuItemIterator=0;menuItemIterator < menuItems.length;menuItemIterator++) { + target = Ext.ClassManager.get(menuItems[menuItemIterator]); + + if (!target) { + console.log("Error: "+menuItems[menuItemIterator] + " not found!"); + } + + if (!target.menuPath) { + console.log("Error: "+menuItems[menuItemIterator] + " has no menuPath defined!"); + } + this.createMenu(target, target.menuPath, this.menu); + } + + this.items = this.menu.menu; + + this.callParent(); + } }); diff --git a/src/PartKeepr/FrontendBundle/Resources/public/js/Components/PartMeasurementUnit/PartMeasurementUnitEditorComponent.js b/src/PartKeepr/FrontendBundle/Resources/public/js/Components/PartMeasurementUnit/PartMeasurementUnitEditorComponent.js @@ -16,5 +16,11 @@ Ext.define('PartKeepr.PartMeasurementUnitEditorComponent', { }); this.callParent(); - } -});- \ No newline at end of file + }, + statics: { + iconCls: 'fugue-icon ruler', + title: i18n('Part Measurement Units'), + closable: true, + menuPath: [{text: i18n("Edit")}] + } +}); diff --git a/src/PartKeepr/FrontendBundle/Resources/public/js/Components/Project/ProjectEditorComponent.js b/src/PartKeepr/FrontendBundle/Resources/public/js/Components/Project/ProjectEditorComponent.js @@ -20,5 +20,11 @@ Ext.define('PartKeepr.ProjectEditorComponent', { }); this.callParent(); + }, + statics: { + iconCls: 'fugue-icon drill', + title: i18n('Projects'), + closable: true, + menuPath: [{ text: i18n("Edit")}] } }); diff --git a/src/PartKeepr/FrontendBundle/Resources/public/js/Components/Project/ProjectReport.js b/src/PartKeepr/FrontendBundle/Resources/public/js/Components/Project/ProjectReport.js @@ -376,5 +376,11 @@ Ext.define('PartKeepr.ProjectReportView', { model: "PartKeepr.ProjectBundle.Entity.ProjectReport", pageSize: -1 }); + }, + statics: { + iconCls: 'fugue-icon drill', + title: i18n('Project Reports'), + closable: true, + menuPath: [{ text: i18n("View")}] } }); diff --git a/src/PartKeepr/FrontendBundle/Resources/public/js/Components/Statistics/CurrentStatisticsPanel.js b/src/PartKeepr/FrontendBundle/Resources/public/js/Components/Statistics/CurrentStatisticsPanel.js @@ -1,92 +0,0 @@ -Ext.define('PartKeepr.CurrentStatisticsPanel', { - extend: 'Ext.panel.Panel', - width: 400, - height: 250, - title: i18n("Current Statistics"), - bodyStyle: { - padding: "5px" - }, - layout: 'fit', - /** - * Initializes the component and adds a template - */ - initComponent: function () { - /** - * Create the template - */ - this.tpl = new Ext.XTemplate( - '<h1>'+i18n("Current Statistics")+'</h1>', - '<table>', - '<tr>', - '<td style="width: 200px;" class="o">'+i18n("Different Parts")+':</td>', - '<td style="width: 200px;" class="o">{partCount}</td>', - '</tr>', - '<tr>', - '<td style="width: 200px;" class="e">'+i18n("Total Part Value")+':</td>', - '<td style="width: 200px;" class="e">{[PartKeepr.getApplication().formatCurrency(values.totalPrice)]}</td>', - '</tr>', - '<tr>', - '<td style="width: 200px;" class="o">'+i18n("Average Part Value")+':</td>', - '<td style="width: 200px;" class="o">{[PartKeepr.getApplication().formatCurrency(values.averagePrice)]}</td>', - '</tr>', - '<tr>', - '<td style="width: 200px;" class="e">'+i18n("Parts with price")+':</td>', - '<td style="width: 200px;" class="e">{partsWithPrice}</td>', - '</tr>', - '<tr>', - '<td style="width: 200px;" class="o">'+i18n("Parts without price")+':</td>', - '<td style="width: 200px;" class="o">{partsWithoutPrice}</td>', - '</tr>', - '<tr>', - '<td class="e">'+i18n("Categories")+':</td>', - '<td class="e">{categoryCount}</td>', - '</tr>', - '</table>', - '<h1>'+i18n("Counts per Unit")+'</h1>', - '<table>', - '<tpl for="units">', - '<tr>', - '<td style="width: 200px;" class="{[xindex % 2 === 0 ? "e" : "o"]}">{name}</td>', - '<td style="width: 200px;" class="{[xindex % 2 === 0 ? "e" : "o"]}">{stockLevel}</td>', - '</tr>', - '</tpl>', - '</table>'); - - this.tbButtons = [{ - text: i18n("Refresh"), - handler: this.loadStats, - scope: this - },{ - text: i18n("Close"), - handler: this.close, - scope: this - }]; - - this.dockedItems = [{ - xtype: 'toolbar', - dock: 'bottom', - ui: 'footer', - items: this.tbButtons - }]; - - this.view = Ext.create("Ext.panel.Panel", { - autoScroll: true - }); - - this.items = this.view; - this.callParent(); - - this.loadStats(); - }, - loadStats: function () { - var call = new PartKeepr.ServiceCall( - "Statistic", - "getCurrentStats"); - - call.setHandler(Ext.bind(this.onStatsLoaded, this)); - call.doCall(); - }, - onStatsLoaded: function (data) { - this.tpl.overwrite(this.view.getTargetEl(), data); - } -});- \ No newline at end of file diff --git a/src/PartKeepr/FrontendBundle/Resources/public/js/Components/Statistics/StatisticsChart.js b/src/PartKeepr/FrontendBundle/Resources/public/js/Components/Statistics/StatisticsChart.js @@ -146,4 +146,4 @@ Ext.define('PartKeepr.StatisticsChart', { this.store.getProxy().extraParams.endDateTime = Ext.Date.format(date, "Y-m-d H:i:s"); } -});- \ No newline at end of file +}); diff --git a/src/PartKeepr/FrontendBundle/Resources/public/js/Components/Statistics/StatisticsChartPanel.js b/src/PartKeepr/FrontendBundle/Resources/public/js/Components/Statistics/StatisticsChartPanel.js @@ -68,5 +68,11 @@ Ext.define('PartKeepr.StatisticsChartPanel', { this.chart.setStart(start); this.chart.setEnd(end); this.chart.store.load(); + }, + statics: { + iconCls: 'web-icon chart_bar', + title: i18n('Chart'), + closable: true, + menuPath: [{text: i18n("View")}, {text: i18n("Statistics"), iconCls: "web-icon chart_bar"}] } -});- \ No newline at end of file +}); diff --git a/src/PartKeepr/FrontendBundle/Resources/public/js/Components/Statistics/SummaryStatisticsPanel.js b/src/PartKeepr/FrontendBundle/Resources/public/js/Components/Statistics/SummaryStatisticsPanel.js @@ -0,0 +1,98 @@ +Ext.define('PartKeepr.SummaryStatisticsPanel', { + extend: 'Ext.panel.Panel', + width: 400, + height: 250, + title: i18n("Current Statistics"), + bodyStyle: { + padding: "5px" + }, + layout: 'fit', + /** + * Initializes the component and adds a template + */ + initComponent: function () { + /** + * Create the template + */ + this.tpl = new Ext.XTemplate( + '<h1>'+i18n("Current Statistics")+'</h1>', + '<table>', + '<tr>', + '<td style="width: 200px;" class="o">'+i18n("Different Parts")+':</td>', + '<td style="width: 200px;" class="o">{partCount}</td>', + '</tr>', + '<tr>', + '<td style="width: 200px;" class="e">'+i18n("Total Part Value")+':</td>', + '<td style="width: 200px;" class="e">{[PartKeepr.getApplication().formatCurrency(values.totalPrice)]}</td>', + '</tr>', + '<tr>', + '<td style="width: 200px;" class="o">'+i18n("Average Part Value")+':</td>', + '<td style="width: 200px;" class="o">{[PartKeepr.getApplication().formatCurrency(values.averagePrice)]}</td>', + '</tr>', + '<tr>', + '<td style="width: 200px;" class="e">'+i18n("Parts with price")+':</td>', + '<td style="width: 200px;" class="e">{partsWithPrice}</td>', + '</tr>', + '<tr>', + '<td style="width: 200px;" class="o">'+i18n("Parts without price")+':</td>', + '<td style="width: 200px;" class="o">{partsWithoutPrice}</td>', + '</tr>', + '<tr>', + '<td class="e">'+i18n("Categories")+':</td>', + '<td class="e">{categoryCount}</td>', + '</tr>', + '</table>', + '<h1>'+i18n("Counts per Unit")+'</h1>', + '<table>', + '<tpl for="units">', + '<tr>', + '<td style="width: 200px;" class="{[xindex % 2 === 0 ? "e" : "o"]}">{name}</td>', + '<td style="width: 200px;" class="{[xindex % 2 === 0 ? "e" : "o"]}">{stockLevel}</td>', + '</tr>', + '</tpl>', + '</table>'); + + this.tbButtons = [{ + text: i18n("Refresh"), + handler: this.loadStats, + scope: this + },{ + text: i18n("Close"), + handler: this.close, + scope: this + }]; + + this.dockedItems = [{ + xtype: 'toolbar', + dock: 'bottom', + ui: 'footer', + items: this.tbButtons + }]; + + this.view = Ext.create("Ext.panel.Panel", { + autoScroll: true + }); + + this.items = this.view; + this.callParent(); + + this.loadStats(); + }, + loadStats: function () { + var call = new PartKeepr.ServiceCall( + "Statistic", + "getCurrentStats"); + + call.setHandler(Ext.bind(this.onStatsLoaded, this)); + call.doCall(); + }, + onStatsLoaded: function (data) { + this.tpl.overwrite(this.view.getTargetEl(), data); + }, + statics: { + iconCls: 'web-icon chart_bar', + title: i18n('Summary'), + closable: true, + menuPath: [{text: i18n("View")}, {text: i18n("Statistics"), iconCls: "web-icon chart_bar"}] + } +}); diff --git a/src/PartKeepr/FrontendBundle/Resources/public/js/Components/StockReport/StockHistoryGrid.js b/src/PartKeepr/FrontendBundle/Resources/public/js/Components/StockReport/StockHistoryGrid.js @@ -2,39 +2,48 @@ * The stock history grid. It shows all stock transactions. */ Ext.define('PartKeepr.StockHistoryGrid', { - extend: 'PartKeepr.AbstractStockHistoryGrid', - alias: 'widget.PartStockHistoryGrid', - - pageSize: 25, - - defineColumns: function () { - this.callParent(); - - this.columns.splice(2, 0, { - header: i18n("Part"), - renderer: Ext.util.Format.htmlEncode, - dataIndex: 'part_name', - flex: 1, - minWidth: 200 - }); - - this.columns.splice(3, 0, { - header: i18n("Storage Location"), - renderer: Ext.util.Format.htmlEncode, - dataIndex: 'storageLocation_name', - flex: 1, - minWidth: 200 - }); - }, - initComponent: function () { - this.callParent(); - - this.on("activate", this.onActivate, this); - }, - /** + extend: 'PartKeepr.AbstractStockHistoryGrid', + alias: 'widget.PartStockHistoryGrid', + + pageSize: 25, + + defineColumns: function () + { + this.callParent(); + + this.columns.splice(2, 0, { + header: i18n("Part"), + renderer: Ext.util.Format.htmlEncode, + dataIndex: 'part_name', + flex: 1, + minWidth: 200 + }); + + this.columns.splice(3, 0, { + header: i18n("Storage Location"), + renderer: Ext.util.Format.htmlEncode, + dataIndex: 'storageLocation_name', + flex: 1, + minWidth: 200 + }); + }, + initComponent: function () + { + this.callParent(); + + this.on("activate", this.onActivate, this); + }, + /** * Called when the view is activated. */ - onActivate: function () { - this.store.load(); + onActivate: function () + { + this.store.load(); + }, + statics: { + iconCls: 'fugue-icon notebook', + title: i18n('Stock History'), + closable: true, + menuPath: [{text: i18n("View")}] } }); diff --git a/src/PartKeepr/FrontendBundle/Resources/public/js/Components/StorageLocation/StorageLocationEditorComponent.js b/src/PartKeepr/FrontendBundle/Resources/public/js/Components/StorageLocation/StorageLocationEditorComponent.js @@ -20,5 +20,11 @@ Ext.define('PartKeepr.StorageLocationEditorComponent', { }); this.callParent(); - } -});- \ No newline at end of file + }, + statics: { + iconCls: 'fugue-icon wooden-box', + title: i18n('Storage Locations'), + closable: true, + menuPath: [{text: i18n("Edit")}] + } +}); diff --git a/src/PartKeepr/FrontendBundle/Resources/public/js/Components/SystemInformation/SystemInformationGrid.js b/src/PartKeepr/FrontendBundle/Resources/public/js/Components/SystemInformation/SystemInformationGrid.js @@ -63,5 +63,11 @@ Ext.define('PartKeepr.SystemInformationGrid', { // Retrieve the system information this.store.load(); + }, + statics: { + iconCls: 'fugue-icon system-monitor', + title: i18n('System Information'), + closable: true, + menuPath: [{text: i18n("View")}] } }); diff --git a/src/PartKeepr/FrontendBundle/Resources/public/js/Components/SystemNotice/SystemNoticeEditorComponent.js b/src/PartKeepr/FrontendBundle/Resources/public/js/Components/SystemNotice/SystemNoticeEditorComponent.js @@ -29,5 +29,11 @@ Ext.define('PartKeepr.SystemNoticeEditorComponent', { }); this.callParent(); + }, + statics: { + iconCls: 'fugue-icon service-bell', + title: i18n('System Notices'), + closable: true, + menuPath: [{text: i18n("View")}] } }); diff --git a/src/PartKeepr/FrontendBundle/Resources/public/js/Components/Unit/UnitEditorComponent.js b/src/PartKeepr/FrontendBundle/Resources/public/js/Components/Unit/UnitEditorComponent.js @@ -16,5 +16,11 @@ Ext.define('PartKeepr.UnitEditorComponent', { }); this.callParent(); - } -});- \ No newline at end of file + }, + statics: { + iconCls: 'partkeepr-icon unit', + title: i18n('Units'), + closable: true, + menuPath: [{text: i18n("Edit")}] + } +}); diff --git a/src/PartKeepr/FrontendBundle/Resources/public/js/Components/User/UserEditorComponent.js b/src/PartKeepr/FrontendBundle/Resources/public/js/Components/User/UserEditorComponent.js @@ -24,5 +24,11 @@ Ext.define('PartKeepr.UserEditorComponent', { }); this.callParent(); + }, + statics: { + iconCls: 'web-icon user', + title: i18n('Users'), + closable: true, + menuPath: [{text: i18n("Edit")}] } }); diff --git a/src/PartKeepr/FrontendBundle/Resources/public/js/Components/User/UserPreferences.js b/src/PartKeepr/FrontendBundle/Resources/public/js/Components/User/UserPreferences.js @@ -1,17 +1,31 @@ Ext.define('PartKeepr.UserPreferencePanel', { - extend: 'Ext.tab.Panel', - title: i18n("User Preferences"), - tabPosition: 'bottom', - //bodyStyle: 'background:#DBDBDB;padding: 10px;', - initComponent: function () { - - this.passwordChangePanel = Ext.create("PartKeepr.UserPasswordChangePanel"); - this.tipsPanel = Ext.create("PartKeepr.TipOfTheDayPreferencesPanel"); - this.formattingPanel = Ext.create("PartKeepr.FormattingPreferencesPanel"); - this.displayPreferencesPanel = Ext.create("PartKeepr.DisplayPreferencesPanel"); - this.stockPanel = Ext.create("PartKeepr.StockPreferencesPanel"); - this.items = [ this.tipsPanel, this.formattingPanel, this.displayPreferencesPanel, this.passwordChangePanel, this.stockPanel ]; - this.callParent(); - } + extend: 'Ext.tab.Panel', + title: i18n("User Preferences"), + tabPosition: 'bottom', + //bodyStyle: 'background:#DBDBDB;padding: 10px;', + initComponent: function () + { + + this.passwordChangePanel = Ext.create("PartKeepr.UserPasswordChangePanel"); + this.tipsPanel = Ext.create("PartKeepr.TipOfTheDayPreferencesPanel"); + this.formattingPanel = Ext.create("PartKeepr.FormattingPreferencesPanel"); + this.displayPreferencesPanel = Ext.create("PartKeepr.DisplayPreferencesPanel"); + this.stockPanel = Ext.create("PartKeepr.StockPreferencesPanel"); + this.items = [ + this.tipsPanel, + this.formattingPanel, + this.displayPreferencesPanel, + this.passwordChangePanel, + this.stockPanel + ]; + this.callParent(); + }, + statics: { + iconCls: 'fugue-icon gear', + title: i18n('User Preferences'), + closable: true, + menuPath: [{text: i18n("System")}] + } + }); diff --git a/src/PartKeepr/FrontendBundle/Resources/public/js/PartKeepr.js b/src/PartKeepr/FrontendBundle/Resources/public/js/PartKeepr.js @@ -6,6 +6,10 @@ Ext.application({ name: 'PartKeepr', loginManager: null, + init: function () { + + + }, launch: function () { Ext.setGlyphFontFamily('FontAwesome'); @@ -23,6 +27,13 @@ Ext.application({ var authenticationProvider = Ext.create(window.parameters.authentication_provider); PartKeepr.Auth.AuthenticationProvider.setAuthenticationProvider(authenticationProvider); + this.control ({ + 'MenuBar menuitem': { + click: this.onAppMenuClick, + scope: this + } + }); + var config = {}; if (window.parameters.autoLoginUsername) { @@ -36,6 +47,19 @@ Ext.application({ this.loginManager.on("logout", this.onLogout, this); this.loginManager.login(); }, + onAppMenuClick: function (item) { + var target = item.target["$className"]; + + var config = { + title: item.target.title, + closable: item.target.closable, + iconCls: item.target.iconCls + }; + + var j = Ext.create(target, config); + PartKeepr.getApplication().addItem(j); + j.show(); + }, getParameter: function (parameter) { if (window.parameters[parameter]) { diff --git a/src/PartKeepr/FrontendBundle/Resources/views/index.html.twig b/src/PartKeepr/FrontendBundle/Resources/views/index.html.twig @@ -201,7 +201,7 @@ '@PartKeeprFrontendBundle/Resources/public/js/Components/Project/ProjectReport.js' '@PartKeeprFrontendBundle/Resources/public/js/Components/Statistics/StatisticsChart.js' '@PartKeeprFrontendBundle/Resources/public/js/Components/Statistics/StatisticsChartPanel.js' - '@PartKeeprFrontendBundle/Resources/public/js/Components/Statistics/CurrentStatisticsPanel.js' + '@PartKeeprFrontendBundle/Resources/public/js/Components/Statistics/SummaryStatisticsPanel.js' '@PartKeeprFrontendBundle/Resources/public/js/Data/store/SystemNoticeStore.js' '@PartKeeprFrontendBundle/Resources/public/js/Components/TipOfTheDay/TipOfTheDayWindow.js' '@PartKeeprFrontendBundle/Resources/public/js/Components/CategoryTree.js'