partkeepr

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

commit ab88a1cb26f5dfd873eeaa24b794823da03d6bc9
parent a9645d25c4bfe2c5a7b42d36d5375d7483d154ea
Author: Timo A. Hummel <felicitus@felicitus.org>
Date:   Sun,  8 Apr 2018 19:28:46 +0200

Added delete method for project reports

Diffstat:
Mapp/config/config_partkeepr.yml | 8+++++++-
Msrc/PartKeepr/FrontendBundle/Resources/public/js/Components/Project/ProjectReport.js | 52++++++++++++++++++++++++++++++++++++----------------
Msrc/PartKeepr/FrontendBundle/Resources/public/js/Components/Project/ProjectReportGrid.js | 14++++++++++++++
3 files changed, 57 insertions(+), 17 deletions(-)

diff --git a/app/config/config_partkeepr.yml b/app/config/config_partkeepr.yml @@ -1329,13 +1329,19 @@ services: factory: [ "@api.operation_factory", "createItemOperation" ] arguments: [ "@resource.project_report", "PUT" ] + resource.project_report.item_operation.delete: + class: "Dunglas\ApiBundle\Api\Operation\Operation" + public: false + factory: [ "@api.operation_factory", "createItemOperation" ] + arguments: [ "@resource.project_report", "DELETE" ] + resource.project_report: parent: "api.resource" arguments: [ "PartKeepr\\ProjectBundle\\Entity\\Report" ] tags: [ { name: "api.resource" } ] calls: - method: "initItemOperations" - arguments: [ [ "@resource.project_report.item_operation.custom_get", "@resource.project_report.item_operation.put" ] ] + arguments: [ [ "@resource.project_report.item_operation.custom_get", "@resource.project_report.item_operation.put", "@resource.project_report.item_operation.delete" ] ] - method: "initCollectionOperations" arguments: [ [ "@resource.project_report.collection_operation.get", "@resource.project_report.item_operation.custom_post"]] - method: "initFilters" diff --git a/src/PartKeepr/FrontendBundle/Resources/public/js/Components/Project/ProjectReport.js b/src/PartKeepr/FrontendBundle/Resources/public/js/Components/Project/ProjectReport.js @@ -19,8 +19,7 @@ Ext.define('PartKeepr.ProjectReportView', { } }, - initComponent: function () - { + initComponent: function () { this.createStores(); this.projectList = Ext.create("PartKeepr.Components.Project.ProjectReportList", { @@ -73,10 +72,10 @@ Ext.define('PartKeepr.ProjectReportView', { this.callParent(); this.down("#createReportButton").on("click", this.onCreateReportClick, this); + this.down("#deleteReportButton").on("click", this.onDeleteReportClick, this); this.down("#loadReportButton").on("click", this.onLoadReportClick, this); }, - onLoadReportClick: function () - { + onLoadReportClick: function () { this.reportResult.getView().mask(i18n("Loading…")); var selection = this.reportList.getSelection(); @@ -93,8 +92,7 @@ Ext.define('PartKeepr.ProjectReportView', { /** * */ - onCreateReportClick: function () - { + onCreateReportClick: function () { this.reportResult.getView().mask(i18n("Loading…")); this.reportResult.setProjectsToReport(this.projectList.getProjectsToReport()); @@ -113,8 +111,34 @@ Ext.define('PartKeepr.ProjectReportView', { this.doSaveProjectReport(); }, - doSaveProjectReport: function () - { + /** + * + */ + onDeleteReportClick: function () { + var selection = this.reportList.getSelection(); + + if (selection.length === 1) + { + + Ext.Msg.confirm(i18n("Delete Report"), sprintf(i18n("Do you really wish to delete the report %s %s?"), selection[0].get("name"), selection[0].get("createDateTime")), + this.deleteReport, this); + } + + }, + deleteReport: function (btn) { + if (btn === "yes") + { + this.reportResult.setProjectsToReport([]); + this.reportResult.setStore(new Ext.data.Store()); + + var selection = this.reportList.getSelection(); + if (selection.length === 1) + { + selection[0].erase(); + } + } + }, + doSaveProjectReport: function () { this.reportResult.getView().mask(i18n("Saving…")); this.reportResult.reconfigure(this.emptyReportPartStore); this.projectReport.save({ @@ -122,8 +146,7 @@ Ext.define('PartKeepr.ProjectReportView', { scope: this }); }, - onProjectReportSave: function () - { + onProjectReportSave: function () { this.projectReport.load({ success: this.onProjectReportLoaded, scope: this @@ -131,8 +154,7 @@ Ext.define('PartKeepr.ProjectReportView', { this.reportList.getStore().reload(); }, - onProjectReportLoaded: function () - { + onProjectReportLoaded: function () { this.reportResult.reconfigure(this.projectReport.reportParts()); this.reportResult.projectReport = this.projectReport; this.reportResult.getView().unmask(); @@ -140,8 +162,7 @@ Ext.define('PartKeepr.ProjectReportView', { /** * Creates the store used in this view. */ - createStores: function () - { + createStores: function () { this.projectReportStore = Ext.create('Ext.data.Store', { model: "PartKeepr.ProjectBundle.Entity.ReportPart", pageSize: -1, @@ -157,5 +178,4 @@ Ext.define('PartKeepr.ProjectReportView', { closable: true, menuPath: [{text: i18n("View")}] } -}) -; +}); diff --git a/src/PartKeepr/FrontendBundle/Resources/public/js/Components/Project/ProjectReportGrid.js b/src/PartKeepr/FrontendBundle/Resources/public/js/Components/Project/ProjectReportGrid.js @@ -4,6 +4,9 @@ Ext.define('PartKeepr.Components.Project.ProjectReportGrid', { extend: 'PartKeepr.BaseGrid', alias: 'widget.ProjectReportGrid', + + reference: 'ProjectReportGrid', + columns: [ {header: i18n("Name"), dataIndex: 'name', flex: 2}, {header: i18n("Created"), dataIndex: 'createDateTime', flex: 1, xtype: 'datecolumn'} @@ -31,7 +34,18 @@ Ext.define('PartKeepr.Components.Project.ProjectReportGrid', { xtype: 'button', text: i18n("Load Report"), iconCls: "fugue-icon notification-counter", + bind: { + disabled: '{!ProjectReportGrid.selection}' + }, itemId: 'loadReportButton' + },{ + xtype: 'button', + text: i18n("Delete Report"), + bind: { + disabled: '{!ProjectReportGrid.selection}' + }, + iconCls: "fugue-icon minus-circle", + itemId: 'deleteReportButton' }] } });