partkeepr

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

commit bad9d1e8c897a38147557b216600942e6981cf86
parent b534e87d69387ba518c06b01c3c709a3d8d9ee39
Author: Felicitus <felicitus@felicitus.org>
Date:   Sat, 31 Dec 2011 13:57:54 +0100

Added system notices

Diffstat:
Msrc/backend/de/RaumZeitLabor/PartKeepr/PartKeepr.php | 5++---
Asrc/backend/de/RaumZeitLabor/PartKeepr/SystemNotice/SystemNotice.php | 120+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Asrc/backend/de/RaumZeitLabor/PartKeepr/SystemNotice/SystemNoticeManager.php | 35+++++++++++++++++++++++++++++++++++
Asrc/backend/de/RaumZeitLabor/PartKeepr/SystemNotice/SystemNoticeService.php | 73+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Msrc/frontend/css/PartKeepr.css | 4++++
Msrc/frontend/js/Components/MenuBar.js | 14++++++++++++++
Asrc/frontend/js/Components/SystemNotice/SystemNoticeEditor.js | 76++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Asrc/frontend/js/Components/SystemNotice/SystemNoticeEditorComponent.js | 22++++++++++++++++++++++
Asrc/frontend/js/Components/SystemNotice/SystemNoticeGrid.js | 12++++++++++++
Asrc/frontend/js/Models/SystemNotice.js | 17+++++++++++++++++
10 files changed, 375 insertions(+), 3 deletions(-)

diff --git a/src/backend/de/RaumZeitLabor/PartKeepr/PartKeepr.php b/src/backend/de/RaumZeitLabor/PartKeepr/PartKeepr.php @@ -97,8 +97,6 @@ class PartKeepr { * @return nothing */ public static function initializeDoctrine () { - - $config = new Configuration; $driverImpl = $config->newDefaultAnnotationDriver( @@ -265,7 +263,8 @@ class PartKeepr { 'de\RaumZeitLabor\PartKeepr\TipOfTheDay\TipOfTheDay', 'de\RaumZeitLabor\PartKeepr\TipOfTheDay\TipOfTheDayHistory', - 'de\RaumZeitLabor\PartKeepr\UserPreference\UserPreference' + 'de\RaumZeitLabor\PartKeepr\UserPreference\UserPreference', + 'de\RaumZeitLabor\PartKeepr\SystemNotice\SystemNotice' ); } diff --git a/src/backend/de/RaumZeitLabor/PartKeepr/SystemNotice/SystemNotice.php b/src/backend/de/RaumZeitLabor/PartKeepr/SystemNotice/SystemNotice.php @@ -0,0 +1,119 @@ +<?php +namespace de\RaumZeitLabor\PartKeepr\SystemNotice; +declare(encoding = 'UTF-8'); + +use de\RaumZeitLabor\PartKeepr\UploadedFile\UploadedFile, + de\RaumZeitLabor\PartKeepr\Util\BaseEntity, + de\RaumZeitLabor\PartKeepr\Util\Serializable, + de\RaumZeitLabor\PartKeepr\Util\Deserializable; + +/** + * Holds a project attachment + * @Entity + **/ +class SystemNotice extends BaseEntity implements Serializable { + /** + * @Column(type="datetime") + * @var \DateTime + */ + private $date; + + /** + * @Column(type="string") + * @var string + */ + private $title; + + /** + * The description of this attachment + * @Column(type="text") + * @var string + */ + private $description; + + /** + * Defines if the system notice has been acknowledged + * @Column(type="boolean") + * @var boolean + */ + private $acknowledged; + + /** + * Sets the date and time for this entry + * @param \DateTime $date The date and time + */ + public function setDate (\DateTime $date) { + $this->date = $date; + } + + /** + * Returns the date and time for this entry + * + * @return \DateTime the date and time for this entry + */ + public function getDate () { + return $this->date; + } + + /** + * Sets the title for this entry + * @param string $title the title for this entry + */ + public function setTitle ($title) { + $this->title = $title; + } + + /** + * Returns the title for this entry + * @return string the title + */ + public function getTitle () { + return $this->title; + } + + /** + * Sets the description + * @param string $description + */ + public function setDescription ($description) { + $this->description = $description; + } + + /** + * Returns the description + * @return string The description + */ + public function getDescription () { + return $this->description; + } + + /** + * Sets the value of the acknowledged flag + * @param boolean $bAck True if the notice should be acknowledged (default), false otherwise + */ + public function setAcknowledgedFlag ($bAck = true) { + $this->acknowledged = $bAck; + } + + /** + * Returns the value of the acknowledged flag + * + * @return boolean true if this notice has been acknowledged, false otherwise + */ + public function getAcknowledgedFlag () { + return $this->acknowledged; + } + /** + * + * Serializes this project attachment + * @return array The serialized project attachment + */ + public function serialize () { + return array( + "id" => $this->getId(), + "date" => $this->getDate()->format("Y-m-d H:i:s"), + "title" => $this->getTitle(), + "description" => $this->getDescription(), + "acknowledged" => $this->getAcknowledgedFlag()); + } +}+ \ No newline at end of file diff --git a/src/backend/de/RaumZeitLabor/PartKeepr/SystemNotice/SystemNoticeManager.php b/src/backend/de/RaumZeitLabor/PartKeepr/SystemNotice/SystemNoticeManager.php @@ -0,0 +1,34 @@ +<?php +namespace de\RaumZeitLabor\PartKeepr\SystemNotice; +declare(encoding = 'UTF-8'); + +use de\RaumZeitLabor\PartKeepr\Manager\AbstractManager, + de\RaumZeitLabor\PartKeepr\Project\Project, + de\RaumZeitLabor\PartKeepr\PartKeepr; + +class SystemNoticeManager extends AbstractManager { + /** + * Returns the FQCN for the target entity to operate on. + * @return string The FQCN, e.g. de\RaumZeitLabor\PartKeepr\Part + */ + public function getEntityName () { + return 'de\RaumZeitLabor\PartKeepr\SystemNotice\SystemNotice'; + } + + /** + * Returns all fields which need to appear in the getList ResultSet. + * @return array An array of all fields which should be returned + */ + public function getQueryFields () { + return array("id", "title", "date"); + } + + /** + * Returns the default sort field + * + * @return string The default sort field + */ + public function getDefaultSortField () { + return "date"; + } +}+ \ No newline at end of file diff --git a/src/backend/de/RaumZeitLabor/PartKeepr/SystemNotice/SystemNoticeService.php b/src/backend/de/RaumZeitLabor/PartKeepr/SystemNotice/SystemNoticeService.php @@ -0,0 +1,72 @@ +<?php +namespace de\RaumZeitLabor\PartKeepr\SystemNotice; +use de\RaumZeitLabor\PartKeepr\Service\RestfulService; + +declare(encoding = 'UTF-8'); + +use de\RaumZeitLabor\PartKeepr\Service\Service; +use de\RaumZeitLabor\PartKeepr\PartKeepr, + de\RaumZeitLabor\PartKeepr\Manager\ManagerFilter; + +class SystemNoticeService extends Service implements RestfulService { + /** + * (non-PHPdoc) + * @see de\RaumZeitLabor\PartKeepr\Service.RestfulService::get() + */ + public function get () { + if ($this->hasParameter("id")) { + return array("data" => SystemNoticeManager::getInstance()->getEntity($this->getParameter("id"))->serialize()); + } else { + $parameters = new ManagerFilter($this); + $parameters->setFilterCallback(array($this, "filterCallback")); + + return SystemNoticeManager::getInstance()->getList($parameters); + } + } + + public function filterCallback ($queryBuilder) { + $queryBuilder->andWhere("q.acknowledged = :acknowledged"); + $queryBuilder->setParameter("acknowledged", false); + } + /** + * Stub method to fulfill the RestfulService. We don't want to have SystemNotices created by the user, so + * we bail out with an exception. + * + * (non-PHPdoc) + * @see de\RaumZeitLabor\PartKeepr\Service.RestfulService::create() + */ + public function create () { + throw new \Exception("Not implemented"); + } + + /** + * Stub method to fulfill the RestfulService. We don't want to have SystemNotices updated by the user, so + * we bail out with an exception. + * + * (non-PHPdoc) + * @see de\RaumZeitLabor\PartKeepr\Service.RestfulService::update() + */ + public function update () { + throw new \Exception("Not implemented"); + + } + + /** + * (non-PHPdoc) + * @see de\RaumZeitLabor\PartKeepr\Service.RestfulService::destroy() + */ + public function destroy () { + $this->requireParameter("id"); + + SystemNoticeManager::getInstance()->deleteEntity($this->getParameter("id")); + + return array("data" => null); + } + + public function acknowledge () { + $this->requireParameter("id"); + + $entity = SystemNoticeManager::getInstance()->getEntity($this->getParameter("id")); + $entity->setAcknowledgedFlag(); + } +}+ \ No newline at end of file diff --git a/src/frontend/css/PartKeepr.css b/src/frontend/css/PartKeepr.css @@ -120,4 +120,8 @@ td.o2 { .icon-drill { background-image: url(../resources/fugue-icons/icons/drill.png) !important; +} + +.icon-service-bell { + background-image: url(../resources/fugue-icons/icons/service-bell.png) !important; } \ No newline at end of file diff --git a/src/frontend/js/Components/MenuBar.js b/src/frontend/js/Components/MenuBar.js @@ -66,6 +66,10 @@ Ext.define('PartKeepr.MenuBar', { text: i18n("Project Reports"), handler: this.showProjectReports, icon: 'resources/fugue-icons/icons/drill.png' + },{ + text: i18n("System Notices"), + handler: this.showSystemNotices, + icon: 'resources/fugue-icons/icons/service-bell.png' } ] }); @@ -243,6 +247,16 @@ Ext.define('PartKeepr.MenuBar', { PartKeepr.getApplication().addItem(j); j.show(); }, + showSystemNotices: function () { + var j = Ext.create("PartKeepr.SystemNoticeEditorComponent", { + title: i18n("System Notices"), + iconCls: 'icon-service-bell', + closable: true + }); + + PartKeepr.getApplication().addItem(j); + j.show(); + }, displayComponent: function (component) { var j = Ext.create(component.type, { title: component.title, diff --git a/src/frontend/js/Components/SystemNotice/SystemNoticeEditor.js b/src/frontend/js/Components/SystemNotice/SystemNoticeEditor.js @@ -0,0 +1,75 @@ +/** + * Represents the system notice editor + */ +Ext.define('PartKeepr.SystemNoticeEditor', { + extend: 'PartKeepr.Editor', + alias: 'widget.SystemNoticeEditor', + + // Various style configurations + saveText: i18n("Save System Notice"), + defaults: { + anchor: '100%', + labelWidth: 110 + }, + layout: { + type: 'vbox', + align : 'stretch', + pack : 'start' + }, + enableButtons: false, + + /** + * Initializes the component + */ + initComponent: function () { + + this.acknowledgeButton = Ext.create("Ext.button.Button", { + text: i18n("Acknowledge Notice"), + icon: 'resources/silkicons/accept.png' + }); + + this.acknowledgeButton.on("click", this.onAcknowledgeClick, this); + + this.bottomToolbar = Ext.create("Ext.toolbar.Toolbar", { + enableOverflow: true, + margin: '10px', + defaults: {minWidth: 100}, + dock: 'bottom', + ui: 'footer', + items: [ this.acknowledgeButton ] + }); + + this.dockedItems = new Array(this.bottomToolbar); + + this.items = [{ + xtype: 'textfield', + readOnly: true, + name: 'title', + fieldLabel: i18n("Title") + },{ + xtype: 'textarea', + readOnly: true, + flex: 1, + name: 'description', + fieldLabel: i18n("Description") + },{ + xtype: 'datefield', + readOnly: true, + hideTrigger: true, + name: 'date', + fieldLabel: i18n("Date") + }]; + + this.callParent(); + }, + onAcknowledgeClick: function () { + var call = new PartKeepr.ServiceCall("SystemNotice", "acknowledge"); + call.setParameter("id", this.record.get("id")); + call.setHandler(Ext.bind(this.onAcknowledged, this)); + call.doCall(); + }, + onAcknowledged: function () { + this.fireEvent("editorClose", this); + this.store.load(); + } +});+ \ No newline at end of file diff --git a/src/frontend/js/Components/SystemNotice/SystemNoticeEditorComponent.js b/src/frontend/js/Components/SystemNotice/SystemNoticeEditorComponent.js @@ -0,0 +1,21 @@ +/** + * Represents the project editor component + */ +Ext.define('PartKeepr.SystemNoticeEditorComponent', { + extend: 'PartKeepr.EditorComponent', + alias: 'widget.SystemNoticeEditorComponent', + navigationClass: 'PartKeepr.SystemNoticeGrid', + editorClass: 'PartKeepr.SystemNoticeEditor', + newItemText: i18n("New System Notice"), + model: 'PartKeepr.SystemNotice', + initComponent: function () { + this.createStore({ + sorters: [{ + property: 'date', + direction:'DESC' + }] + }); + + this.callParent(); + } +});+ \ No newline at end of file diff --git a/src/frontend/js/Components/SystemNotice/SystemNoticeGrid.js b/src/frontend/js/Components/SystemNotice/SystemNoticeGrid.js @@ -0,0 +1,11 @@ +/** + * Represents the project grid + */ +Ext.define('PartKeepr.SystemNoticeGrid', { + extend: 'PartKeepr.EditorGrid', + alias: 'widget.SystemNoticeGrid', + columns: [ + {header: i18n("Name"), dataIndex: 'title', flex: 1} + ], + enableTopToolbar: false +});+ \ No newline at end of file diff --git a/src/frontend/js/Models/SystemNotice.js b/src/frontend/js/Models/SystemNotice.js @@ -0,0 +1,16 @@ +/** + * Represents a system notice + */ +Ext.define("PartKeepr.SystemNotice", { + extend: "Ext.data.Model", + fields: [ + { id: 'id', name: 'id', type: 'int' }, + { name: 'date', type: 'date', dateFormat: 'Y-m-d H:i:s'}, + { name: 'title', type: 'string'}, + { name: 'description', type: 'string'} + ], + proxy: PartKeepr.getRESTProxy("SystemNotice"), + getRecordName: function () { + return this.get("title"); + } +});+ \ No newline at end of file