diff --git a/doc/Entwicklerhandbuch.md b/doc/Entwicklerhandbuch.md index 508c082..8a6ab77 100644 --- a/doc/Entwicklerhandbuch.md +++ b/doc/Entwicklerhandbuch.md @@ -12,8 +12,9 @@ 1. [Mehrschichtenarchitektur](#42-mehrschichtenarchitektur) 1. [Web-Service-Architektur](#43-web-service-architektur) 1. [Entwurfsmuster](#44-entwurfsmuster) -1. [Logfunktion](#5-logfunktion) -1. [Releasemanagement](#6-releasemanagement) +1. [Benutzerführung](#5-benutzerfhrung) +1. [Logfunktion](#6-logfunktion) +1. [Releasemanagement](#7-releasemanagement) ## 1. Entwicklungsumgebung @@ -123,12 +124,30 @@ Ein oder mehrere *Beobachter* können sich bei einem *Subjekt* für ein oder meh ![Beobachtermuster am Beispiel der WebServiceClients und ViewModels des AblageTypes](Beobachter.jpg) *Abbildung 3 - Beobachtermuster am Beispiel der WebServiceClients und ViewModels des AblageTypes* + +## 5. Benutzerführung + +Das Konzept der Benutzerführung (User Experience - UX) gliedert sich in mehrere Aspekte. Zu den wichtigsten Themen gehört die Definition der Zielgruppen, die mit der Anwendung zu tun haben. An ihnen orientiert sich das im Folgenden beschriebene Benutzungskonzept. + +### 5.1. Zielgruppen + +Die Anwendung richtet sich an unterschiedliche Zielgruppen (Stakeholder), die unterschiedliche Ziele, Wünsche, Fertigkeiten und Erfahrungen haben. In diesem Kapitel werden die Zielgruppen durch [Personas](https://en.wikipedia.org/wiki/Persona_(user_experience)) wiedergegeben. Es sei darauf hingewiesen, dass die Vollständigkeit der Beschreibung und die Priorisierung einer Persona von der Entwicklung der Applikation abhängt. Weil aus praktischen und logischen Gründen Daten zuerst eingegeben werden müssen, bevor sie durchsucht oder analysiert werden können, werden Personas bevorzugt beschrieben, die überwiegend Daten eingeben. Dies kann beispielsweise im Rahmen einer Inventur geschehen. + +#### 5.1.1. Archivarin + +Die Persona *Archivarin* heißt Gabi, ist 55 Jahre alt, verheiratet und hat zwei Kinder, die bereits außer Haus sind. Sie ist schon seit zehn Jahren in der archäologischen Arbeitsgruppe des Ortes tätig und gehört zu den aktiven Mitgliedern. Gabi hat ein abgeschlossenes Studium der Völkerkunde und arbeitet für ein Museum, für das sie Schriften anferrtigt und Vorträge hält. Im Bereich von Text- und Tabellenprogrammen hat Gabi grundlegende Kenntnisse. Weil man bei Softwareprogrammen jedoch an sie viele Dinge mitdenken muss, z. B. Vorbereiten von Daten, wünscht sie sich ein System, das "mitdenkt", sie führt, sodass sie mit wenig Aufwand ihr Ziel erreicht. + +Als Archivarin empfielt Gabi Richtlinien für die Verwaltung des Archivs und sorgt für deren Einhaltung. + +### 5.1. Systembenachrichtigungen + +Das System erzeugt an mehreren Stellen der verschiedenen Anwendungsteile unterschiedliche Nachrichten. Diese richten sich an unterschiedliche Zielgruppen. -## 5. Logfunktion +## 6. Logfunktion Eine wesentliche Neuerung auf der Serverseite ist das Protokollieren des Programmablaufes und der verarbeiteten Daten mittels log4php. Dies unterstützt sowohl den Entwicklungsprozess, als auch die Fehlersuche im Produktivsystem. -## 6. Releasemanagement +## 7. Releasemanagement Jedes Jahr soll es eine Hauptversion geben. Dazwischen soll mindestens eine Zwischenversion erscheinen. Der Zweck der Zwischenversion ist, die "Must Have"-Anforderungen umzusetzen und Rückmeldungen der Anwender für die Hauptversion zu sammeln. Die nachfolgenden Zwischenversionen oder die Hauptversion setzen das Benutzer-Feedback um und ergänzen die Anwendung um Funktionen der Kategorie "Should Have" und "Nice To Have". diff --git a/src/AblageType/Form.html b/src/AblageType/Form.html index 944b469..7139daa 100644 --- a/src/AblageType/Form.html +++ b/src/AblageType/Form.html @@ -18,13 +18,15 @@ + + - - + + @@ -53,11 +55,38 @@
-
+

Formular

-
+ +
+
+ + +
+
+
+ +
+
+
+
+ + +
+
+
+ +
+
+
\ No newline at end of file diff --git a/src/AblageType/List.html b/src/AblageType/List.html new file mode 100644 index 0000000..8538c4b --- /dev/null +++ b/src/AblageType/List.html @@ -0,0 +1,71 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Ablagetyp + + + + + +
+
+
+

Liste

+ +
+
+
+
+
+ \ No newline at end of file diff --git a/src/Fund/Form.html b/src/Fund/Form.html index c10b352..4a3dc2b 100644 --- a/src/Fund/Form.html +++ b/src/Fund/Form.html @@ -73,6 +73,12 @@
+
@@ -166,12 +172,6 @@
-
- - - - -
diff --git a/src/FundAttributType/Form.html b/src/FundAttributType/Form.html index 1789b09..b4631b2 100644 --- a/src/FundAttributType/Form.html +++ b/src/FundAttributType/Form.html @@ -1,5 +1,6 @@ + @@ -17,17 +18,19 @@ + + - - + + - + @@ -47,15 +50,43 @@ Fundattributtyp - + +
-
-
-

Formular

-
+
+
+

Formular

+ +
+
+ + +
+
+
+ +
+
+
+
+ + +
+
+
+ +
+
-
-
+
+
+
\ No newline at end of file diff --git a/src/FundAttributType/List.html b/src/FundAttributType/List.html new file mode 100644 index 0000000..46ecf5e --- /dev/null +++ b/src/FundAttributType/List.html @@ -0,0 +1,71 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Fundattributtyp + + + + + +
+
+
+

Liste

+ +
+
+
+
+
+ \ No newline at end of file diff --git a/src/OrtType/Form.html b/src/OrtType/Form.html index d625863..88324a3 100644 --- a/src/OrtType/Form.html +++ b/src/OrtType/Form.html @@ -1,5 +1,6 @@ + @@ -7,7 +8,7 @@ - + @@ -17,13 +18,15 @@ + + - - + + @@ -47,15 +50,43 @@ Ortstyp - + +
-
-
-

Formular

-
+
+
+

Formular

+ +
+
+ + +
+
+
+ +
+
+
+
+ + +
+
+
+ +
+
-
-
+
+
+
\ No newline at end of file diff --git a/src/OrtType/List.html b/src/OrtType/List.html new file mode 100644 index 0000000..16ab53a --- /dev/null +++ b/src/OrtType/List.html @@ -0,0 +1,71 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Ortstyp + + + + + +
+
+
+

Liste

+ +
+
+
+
+
+ \ No newline at end of file diff --git a/src/Services/AblageType.php b/src/Services/AblageType.php index 6d76b6d..548f15d 100644 --- a/src/Services/AblageType.php +++ b/src/Services/AblageType.php @@ -3,6 +3,7 @@ ini_set("display_errors", 1); require_once("../Factory/AblageTypeFactory.php"); +require_once("../UserStories/Ablage/Type/ConvertAblageType.php"); require_once("../UserStories/Ablage/Type/LoadAblageType.php"); require_once("../UserStories/Ablage/Type/LoadAblageTypes.php"); require_once("../UserStories/Ablage/Type/SaveAblageType.php"); @@ -31,9 +32,20 @@ function Create() $logger->info("Ablagetyp-anlegen gestartet"); parse_str(file_get_contents("php://input"), $ablageTypeObject); + + $convertAblageType = new ConvertAblageType(); + $convertAblageType->setMultidimensionalArray($ablageTypeObject); - $ablageTypeFactory = new AblageTypeFactory(); - $ablageType = $ablageTypeFactory->convertToInstance($ablageTypeObject); + if ($convertAblageType->run()) + { + $ablageType = $convertAblageType->getAblageType(); + } + else + { + http_response_code(500); + echo json_encode($convertAblageType->getMessages()); + return; + } $saveAblageType = new SaveAblageType(); $saveAblageType->setAblageType($ablageType); @@ -62,9 +74,20 @@ function Update() { $ablageTypeObject["Id"] = $_GET["Id"]; } + + $convertAblageType = new ConvertAblageType(); + $convertAblageType->setMultidimensionalArray($ablageTypeObject); - $ablageTypeFactory = new AblageTypeFactory(); - $ablageType = $ablageTypeFactory->convertToInstance($ablageTypeObject); + if ($convertAblageType->run()) + { + $ablageType = $convertAblageType->getAblageType(); + } + else + { + http_response_code(500); + echo json_encode($convertAblageType->getMessages()); + return; + } $saveAblageType = new SaveAblageType(); $saveAblageType->setAblageType($ablageType); diff --git a/src/Services/FundAttributType.php b/src/Services/FundAttributType.php index 3442996..ca6f019 100644 --- a/src/Services/FundAttributType.php +++ b/src/Services/FundAttributType.php @@ -3,6 +3,7 @@ ini_set("display_errors", 1); require_once("../Factory/FundAttributTypeFactory.php"); +require_once("../UserStories/FundAttribut/Type/ConvertFundAttributType.php"); require_once("../UserStories/FundAttribut/Type/LoadFundAttributType.php"); require_once("../UserStories/FundAttribut/Type/LoadFundAttributTypes.php"); require_once("../UserStories/FundAttribut/Type/SaveFundAttributType.php"); @@ -31,9 +32,20 @@ function Create() $logger->info("Fundattributtyp-anlegen gestartet"); parse_str(file_get_contents("php://input"), $fundAttributTypeObject); + + $convertFundAttributType = new ConvertFundAttributType(); + $convertFundAttributType->setMultidimensionalArray($fundAttributTypeObject); - $fundAttributTypeFactory = new FundAttributTypeFactory(); - $fundAttributType = $fundAttributTypeFactory->convertToInstance($fundAttributTypeObject); + if ($convertFundAttributType->run()) + { + $fundAttributType = $convertFundAttributType->getFundAttributType(); + } + else + { + http_response_code(500); + echo json_encode($convertFundAttributType->getMessages()); + return; + } $saveFundAttributType = new SaveFundAttributType(); $saveFundAttributType->setFundAttributType($fundAttributType); @@ -60,11 +72,22 @@ function Update() if (isset($_GET["Id"])) { - $fundAttributTypeObject->setId(intval($_GET["Id"])); + $fundAttributTypeObject["Id"] = $_GET["Id"]; } + + $convertFundAttributType = new ConvertFundAttributType(); + $convertFundAttributType->setMultidimensionalArray($fundAttributTypeObject); - $fundAttributTypeFactory = new FundAttributTypeFactory(); - $fundAttributType = $fundAttributTypeFactory->convertToInstance($fundAttributTypeObject); + if ($convertFundAttributType->run()) + { + $fundAttributType = $convertFundAttributType->getFundAttributType(); + } + else + { + http_response_code(500); + echo json_encode($convertFundAttributType->getMessages()); + return; + } $saveFundAttributType = new SaveFundAttributType(); $saveFundAttributType->setFundAttributType($fundAttributType); diff --git a/src/Services/OrtType.php b/src/Services/OrtType.php index 95be21c..3ccbd3e 100644 --- a/src/Services/OrtType.php +++ b/src/Services/OrtType.php @@ -3,6 +3,7 @@ ini_set("display_errors", 1); require_once("../Factory/OrtTypeFactory.php"); +require_once("../UserStories/Ort/Type/ConvertOrtType.php"); require_once("../UserStories/Ort/Type/LoadOrtType.php"); require_once("../UserStories/Ort/Type/LoadOrtTypes.php"); require_once("../UserStories/Ort/Type/SaveOrtType.php"); @@ -31,9 +32,20 @@ function Create() $logger->info("Ortstyp-anlegen gestartet"); parse_str(file_get_contents("php://input"), $ortTypeObject); + + $convertOrtType = new ConvertOrtType(); + $convertOrtType->setMultidimensionalArray($ortTypeObject); - $ortTypeFactory = new OrtTypeFactory(); - $ortType = $ortTypeFactory->convertToInstance($ortTypeObject); + if ($convertOrtType->run()) + { + $ortType = $convertOrtType->getOrtType(); + } + else + { + http_response_code(500); + echo json_encode($convertOrtType->getMessages()); + return; + } $saveOrtType = new SaveOrtType(); $saveOrtType->setOrtType($ortType); @@ -62,9 +74,20 @@ function Update() { $ortTypeObject["Id"] = $_GET["Id"]; } + + $convertOrtType = new ConvertOrtType(); + $convertOrtType->setMultidimensionalArray($ortTypeObject); - $ortTypeFactory = new OrtTypeFactory(); - $ortType = $ortTypeFactory->convertToInstance($ortTypeObject); + if ($convertOrtType->run()) + { + $ortType = $convertOrtType->getOrtType(); + } + else + { + http_response_code(500); + echo json_encode($convertOrtType->getMessages()); + return; + } $saveOrtType = new SaveOrtType(); $saveOrtType->setOrtType($ortType); diff --git a/src/Services/sitemap.json b/src/Services/sitemap.json index a2ef5be..7f219a8 100644 --- a/src/Services/sitemap.json +++ b/src/Services/sitemap.json @@ -142,18 +142,54 @@ [ { "Title" : "Ablagetypen verwalten", + "URL" : "/Munins Archiv/src/AblageType/List.html", + "PageName" : "AblageTypeList" + }, + { + "Title" : "Ablage neu anlegen", "URL" : "/Munins Archiv/src/AblageType/Form.html", - "PageName" : "AblageTypeManagement" + "PageName" : "AblageTypeFormNew", + "Visible" : false + }, + { + "Title" : "Ablage bearbeiten", + "URL" : "/Munins Archiv/src/AblageType/Form.html", + "PageName" : "AblageTypeFormEdit", + "Visible" : false }, { "Title" : "Ortstypen verwalten", + "URL" : "/Munins Archiv/src/OrtType/List.html", + "PageName" : "OrtTypeList" + }, + { + "Title" : "Ort neu anlegen", "URL" : "/Munins Archiv/src/OrtType/Form.html", - "PageName" : "OrtTypeManagement" + "PageName" : "OrtTypeFormNew", + "Visible" : false }, { - "Title" : "Fundattributstypen verwalten", + "Title" : "Ort bearbeiten", + "URL" : "/Munins Archiv/src/OrtType/Form.html", + "PageName" : "OrtTypeFormEdit", + "Visible" : false + }, + { + "Title" : "Fundattributtypen verwalten", + "URL" : "/Munins Archiv/src/FundAttributType/List.html", + "PageName" : "FundAttributTypeList" + }, + { + "Title" : "Fundattributtyp neu anlegen", "URL" : "/Munins Archiv/src/FundAttributType/Form.html", - "PageName" : "FundAttributTypeManagement" + "PageName" : "FundAttributTypeFormNew", + "Visible" : false + }, + { + "Title" : "Fundattributtyp bearbeiten", + "URL" : "/Munins Archiv/src/FundAttributType/Form.html", + "PageName" : "FundAttributTypeFormEdit", + "Visible" : false } ] }, diff --git a/src/UserStories/Ablage/Type/ConvertAblageType.php b/src/UserStories/Ablage/Type/ConvertAblageType.php new file mode 100644 index 0000000..feab8a2 --- /dev/null +++ b/src/UserStories/Ablage/Type/ConvertAblageType.php @@ -0,0 +1,109 @@ +_multidimensionalArray; + } + + /** + * Sets the multidimensional array, which is to be converted. + * @param Array $multidimensionalArray multidimensional array, which is to convert. + */ + public function setMultidimensionalArray($multidimensionalArray) + { + $this->_multidimensionalArray = $multidimensionalArray; + } + #endregion + + #region output properties + /** + * Returns the converted Ablagetyp. + */ + public function getAblageType() + { + return $this->_ablageType; + } + + /** + * Sets the converted Ablagetyp. + * @param AblageType $ablageType Ablagetyp, which was converted. + */ + private function setAblageType($ablageType) + { + $this->_ablageType = $ablageType; + } + #endregion + #endregion + + #region constructors + function __construct() + { + } + #endregion + + /** + * Is always true. + */ + protected function areParametersValid() + { + return true; + } + + protected function execute() + { + $multidimensionalArray = $this->getMultidimensionalArray(); + + if ($multidimensionalArray == null) + { + $this->addMessage("Es wurden keine Daten übergeben!"); + $this->setAblageType(null); + return false; + } + + $ablageType = new AblageType(); + + #region Id + if (isset($multidimensionalArray["Id"]) && + !empty($multidimensionalArray["Id"])) + { + if (!is_numeric($multidimensionalArray["Id"])) + { + $this->addMessage("Id muss eine Zahl sein!"); + } + else if(intval($multidimensionalArray["Id"]) < 0) + { + $this->addMessage("Id muss mindestens 0 sein!"); + } + else + { + $ablageType->setId(intval($multidimensionalArray["Id"])); + } + } + #endregion + + #region Bezeichnung + if (isset($multidimensionalArray["Bezeichnung"])) + { + $ablageType->setBezeichnung($multidimensionalArray["Bezeichnung"]); + } + #endregion + + $this->setAblageType($ablageType); + + return (count($this->getMessages()) == 0); + } +} \ No newline at end of file diff --git a/src/UserStories/Ablage/Type/SaveAblageType.php b/src/UserStories/Ablage/Type/SaveAblageType.php index 83367b5..b7e4df0 100644 --- a/src/UserStories/Ablage/Type/SaveAblageType.php +++ b/src/UserStories/Ablage/Type/SaveAblageType.php @@ -34,6 +34,11 @@ protected function areParametersValid() $this->addMessage("Bezeichnung ist nicht gesetzt!"); return false; } + else if (strlen($ablageType->getBezeichnung()) > 30) + { + $this->addMessage("Bezeichnung darf nicht länger als 30 Zeichen sein!"); + return false; + } $ablageTypeFactory = new AblageTypeFactory(); $ablageTypes = $ablageTypeFactory->loadAll(); @@ -56,7 +61,21 @@ protected function areParametersValid() protected function execute() { $ablageTypeFactory = new AblageTypeFactory(); - $this->setAblageType($ablageTypeFactory->save($this->getAblageType())); + + $savedAblageType = $ablageTypeFactory->save($this->getAblageType()); + + $loadAblageType = new LoadAblageType(); + $loadAblageType->setId($savedAblageType->getId()); + + if (!$loadAblageType->run()) + { + $this->addMessages($loadAblageType->getMessages()); + return false; + } + + $ablageTypeFromDatabase = $loadAblageType->getAblageType(); + + $this->setAblageType($ablageTypeFromDatabase); return true; } diff --git a/src/UserStories/Fund/ConvertFund.php b/src/UserStories/Fund/ConvertFund.php index d0d1167..d5bfac6 100644 --- a/src/UserStories/Fund/ConvertFund.php +++ b/src/UserStories/Fund/ConvertFund.php @@ -44,7 +44,7 @@ public function getFund() } /** - * Sets the conbverted Fund. + * Sets the converted Fund. * @param Fund $fund Fund, which was converted. */ private function setFund($fund) diff --git a/src/UserStories/Fund/SaveFund.php b/src/UserStories/Fund/SaveFund.php index 8498bbc..33eeba9 100644 --- a/src/UserStories/Fund/SaveFund.php +++ b/src/UserStories/Fund/SaveFund.php @@ -35,6 +35,12 @@ protected function areParametersValid() $this->addMessage("Fund ist nicht gesetzt!"); return false; } + + if (strlen($fund->getBezeichnung()) > 30) + { + $this->addMessage("Bezeichnung darf nicht länger als 30 Zeichen sein!"); + return false; + } return true; } diff --git a/src/UserStories/FundAttribut/Type/ConvertFundAttributType.php b/src/UserStories/FundAttribut/Type/ConvertFundAttributType.php new file mode 100644 index 0000000..abddc64 --- /dev/null +++ b/src/UserStories/FundAttribut/Type/ConvertFundAttributType.php @@ -0,0 +1,109 @@ +_multidimensionalArray; + } + + /** + * Sets the multidimensional array, which is to be converted. + * @param Array $multidimensionalArray multidimensional array, which is to convert. + */ + public function setMultidimensionalArray($multidimensionalArray) + { + $this->_multidimensionalArray = $multidimensionalArray; + } + #endregion + + #region output properties + /** + * Returns the converted Fundattributtyp. + */ + public function getFundAttributType() + { + return $this->_fundAttributType; + } + + /** + * Sets the converted Fundattributtyp. + * @param FundAttributType $fundAttributType Fundattributtyp, which was converted. + */ + private function setFundAttributType($fundAttributType) + { + $this->_fundAttributType = $fundAttributType; + } + #endregion + #endregion + + #region constructors + function __construct() + { + } + #endregion + + /** + * Is always true. + */ + protected function areParametersValid() + { + return true; + } + + protected function execute() + { + $multidimensionalArray = $this->getMultidimensionalArray(); + + if ($multidimensionalArray == null) + { + $this->addMessage("Es wurden keine Daten übergeben!"); + $this->setFundAttributType(null); + return false; + } + + $fundAttributType = new FundAttributType(); + + #region Id + if (isset($multidimensionalArray["Id"]) && + !empty($multidimensionalArray["Id"])) + { + if (!is_numeric($multidimensionalArray["Id"])) + { + $this->addMessage("Id muss eine Zahl sein!"); + } + else if(intval($multidimensionalArray["Id"]) < 0) + { + $this->addMessage("Id muss mindestens 0 sein!"); + } + else + { + $fundAttributType->setId(intval($multidimensionalArray["Id"])); + } + } + #endregion + + #region Bezeichnung + if (isset($multidimensionalArray["Bezeichnung"])) + { + $fundAttributType->setBezeichnung($multidimensionalArray["Bezeichnung"]); + } + #endregion + + $this->setFundAttributType($fundAttributType); + + return (count($this->getMessages()) == 0); + } +} \ No newline at end of file diff --git a/src/UserStories/FundAttribut/Type/SaveFundAttributType.php b/src/UserStories/FundAttribut/Type/SaveFundAttributType.php index c8f9300..4d8d494 100644 --- a/src/UserStories/FundAttribut/Type/SaveFundAttributType.php +++ b/src/UserStories/FundAttribut/Type/SaveFundAttributType.php @@ -25,6 +25,13 @@ public function setFundAttributType($fundAttributType) protected function areParametersValid() { $fundAttributType = $this->getFundAttributType(); + + if (strlen($fundAttributType->getBezeichnung()) > 25) + { + $this->addMessage("Bezeichnung darf nicht länger als 25 Zeichen sein!"); + return false; + } + $fundAttributTypeFactory = new FundAttributTypeFactory(); $fundAttributTypes = $fundAttributTypeFactory->loadAll(); @@ -45,7 +52,21 @@ protected function areParametersValid() protected function execute() { $fundAttributTypeFactory = new FundAttributTypeFactory(); - $this->setFundAttributType($fundAttributTypeFactory->save($this->getFundAttributType())); + + $savedFundAttributType = $fundAttributTypeFactory->save($this->getFundAttributType()); + + $loadFundAttributType = new LoadFundAttributType(); + $loadFundAttributType->setId($savedFundAttributType->getId()); + + if (!$loadFundAttributType->run()) + { + $this->addMessages($loadFundAttributType->getMessages()); + return false; + } + + $fundAttributTypeFromDatabase = $loadFundAttributType->getFundAttributType(); + + $this->setFundAttributType($fundAttributTypeFromDatabase); return true; } diff --git a/src/UserStories/Kontext/Type/ConvertKontextType.php b/src/UserStories/Kontext/Type/ConvertKontextType.php new file mode 100644 index 0000000..592b675 --- /dev/null +++ b/src/UserStories/Kontext/Type/ConvertKontextType.php @@ -0,0 +1,116 @@ +_multidimensionalArray; + } + + /** + * Sets the multidimensional array, which is to be converted. + * @param Array $multidimensionalArray multidimensional array, which is to convert. + */ + public function setMultidimensionalArray($multidimensionalArray) + { + $this->_multidimensionalArray = $multidimensionalArray; + } + #endregion + + #region output properties + /** + * Returns the converted Kontexttyp. + */ + public function getKontextType() + { + return $this->_kontextType; + } + + /** + * Sets the converted Kontexttyp. + * @param KontextType $kontextType Kontexttyp, which was converted. + */ + private function setKontextType($kontextType) + { + $this->_kontextType = $kontextType; + } + #endregion + #endregion + + #region constructors + function __construct() + { + } + #endregion + + /** + * Is always true. + */ + protected function areParametersValid() + { + return true; + } + + protected function execute() + { + $multidimensionalArray = $this->getMultidimensionalArray(); + + if ($multidimensionalArray == null) + { + $this->addMessage("Es wurden keine Daten übergeben!"); + $this->setKontextType(null); + return false; + } + + $kontextType = new KontextType(); + + #region Id + if (isset($multidimensionalArray["Id"]) && + !empty($multidimensionalArray["Id"])) + { + if (!is_numeric($multidimensionalArray["Id"])) + { + $this->addMessage("Id muss eine Zahl sein!"); + } + else if(intval($multidimensionalArray["Id"]) < 0) + { + $this->addMessage("Id muss mindestens 0 sein!"); + } + else + { + $kontextType->setId(intval($multidimensionalArray["Id"])); + } + } + #endregion + + #region Bezeichnung + if (isset($multidimensionalArray["Bezeichnung"])) + { + if (strlen($multidimensionalArray["Bezeichnung"]) > 30) + { + $this->addMessage("Bezeichnung darf nicht länger als 30 Zeichen sein!"); + } + else + { + $kontextType->setBezeichnung($multidimensionalArray["Bezeichnung"]); + } + } + #endregion + + $this->setKontextType($kontextType); + + return (count($this->getMessages()) == 0); + } +} \ No newline at end of file diff --git a/src/UserStories/Ort/Type/ConvertOrtType.php b/src/UserStories/Ort/Type/ConvertOrtType.php new file mode 100644 index 0000000..f302b60 --- /dev/null +++ b/src/UserStories/Ort/Type/ConvertOrtType.php @@ -0,0 +1,109 @@ +_multidimensionalArray; + } + + /** + * Sets the multidimensional array, which is to be converted. + * @param Array $multidimensionalArray multidimensional array, which is to convert. + */ + public function setMultidimensionalArray($multidimensionalArray) + { + $this->_multidimensionalArray = $multidimensionalArray; + } + #endregion + + #region output properties + /** + * Returns the converted Orttyp. + */ + public function getOrtType() + { + return $this->_ortType; + } + + /** + * Sets the converted Orttyp. + * @param OrtType $ortType Orttyp, which was converted. + */ + private function setOrtType($ortType) + { + $this->_ortType = $ortType; + } + #endregion + #endregion + + #region constructors + function __construct() + { + } + #endregion + + /** + * Is always true. + */ + protected function areParametersValid() + { + return true; + } + + protected function execute() + { + $multidimensionalArray = $this->getMultidimensionalArray(); + + if ($multidimensionalArray == null) + { + $this->addMessage("Es wurden keine Daten übergeben!"); + $this->setOrtType(null); + return false; + } + + $ortType = new OrtType(); + + #region Id + if (isset($multidimensionalArray["Id"]) && + !empty($multidimensionalArray["Id"])) + { + if (!is_numeric($multidimensionalArray["Id"])) + { + $this->addMessage("Id muss eine Zahl sein!"); + } + else if(intval($multidimensionalArray["Id"]) < 0) + { + $this->addMessage("Id muss mindestens 0 sein!"); + } + else + { + $ortType->setId(intval($multidimensionalArray["Id"])); + } + } + #endregion + + #region Bezeichnung + if (isset($multidimensionalArray["Bezeichnung"])) + { + $ortType->setBezeichnung($multidimensionalArray["Bezeichnung"]); + } + #endregion + + $this->setOrtType($ortType); + + return (count($this->getMessages()) == 0); + } +} \ No newline at end of file diff --git a/src/UserStories/Ort/Type/SaveOrtType.php b/src/UserStories/Ort/Type/SaveOrtType.php index de04a39..b58e5ec 100644 --- a/src/UserStories/Ort/Type/SaveOrtType.php +++ b/src/UserStories/Ort/Type/SaveOrtType.php @@ -25,6 +25,13 @@ public function setOrtType($ortType) protected function areParametersValid() { $ortType = $this->getOrtType(); + + if (strlen($ortType->getBezeichnung()) > 25) + { + $this->addMessage("Bezeichnung darf nicht länger als 25 Zeichen sein!"); + return false; + } + $ortTypeFactory = new OrtTypeFactory(); $ortTypes = $ortTypeFactory->loadAll(); @@ -45,7 +52,21 @@ protected function areParametersValid() protected function execute() { $ortTypeFactory = new OrtTypeFactory(); - $this->setOrtType($ortTypeFactory->save($this->getOrtType())); + + $savedOrtType = $ortTypeFactory->save($this->getOrtType()); + + $loadOrtType = new LoadOrtType(); + $loadOrtType->setId($savedOrtType->getId()); + + if (!$loadOrtType->run()) + { + $this->addMessages($loadOrtType->getMessages()); + return false; + } + + $ortTypeFromDatabase = $loadOrtType->getOrtType(); + + $this->setOrtType($ortTypeFromDatabase); return true; } diff --git a/src/css/form.css b/src/css/form.css index ec2161d..a9657c4 100644 --- a/src/css/form.css +++ b/src/css/form.css @@ -73,4 +73,14 @@ input[type="button"] { .formBlock .fieldBlock ul { margin-top: 0px; +} + +#toolBar { + list-style-type: none; + margin: 0; + padding: 5px 0px 5px 5px; +} + +#toolBar li { + display: inline; } \ No newline at end of file diff --git a/src/css/grid.css b/src/css/grid.css new file mode 100644 index 0000000..ec186be --- /dev/null +++ b/src/css/grid.css @@ -0,0 +1,13 @@ +/* Overwriting styles of the jsGrid */ + +.jsgrid-selected-row > .jsgrid-cell { + background-color: #fdf5ce; + border-color: #fbcb09; + color: #c77405; +} + +.selectedRow > .jsgrid-cell { + background-color: #f6a828; + border-color: #e78f08; + color: #ffffff; +} \ No newline at end of file diff --git a/src/css/page.css b/src/css/page.css index 9543902..d470689 100644 --- a/src/css/page.css +++ b/src/css/page.css @@ -69,6 +69,10 @@ html, body { color:#333333; } +.linkButton label { + padding-left: 5px; +} + .linkButton:hover { color:azure; background-color: SteelBlue; @@ -94,7 +98,6 @@ html, body { background-color: inherit; } - /**************/ /* visibility */ /**************/ diff --git a/src/js/factories/viewModelFactory.js b/src/js/factories/viewModelFactory.js index 19362bb..7a7bbc3 100644 --- a/src/js/factories/viewModelFactory.js +++ b/src/js/factories/viewModelFactory.js @@ -1,4 +1,31 @@ var ViewModelFactory = function () { + this.getViewModelFormAblageType = function() + { + var webServiceClientFactory = new WebServiceClientFactory(); + var viewModel = new ViewModelFormAblageType(webServiceClientFactory.getWebServiceClientAblageType()); + viewModel.init(); + + return viewModel; + }; + + this.getViewModelFormFundAttributType = function() + { + var webServiceClientFactory = new WebServiceClientFactory(); + var viewModel = new ViewModelFormFundAttributType(webServiceClientFactory.getWebServiceClientFundAttributType()); + viewModel.init(); + + return viewModel; + }; + + this.getViewModelFormOrtType = function() + { + var webServiceClientFactory = new WebServiceClientFactory(); + var viewModel = new ViewModelFormOrtType(webServiceClientFactory.getWebServiceClientOrtType()); + viewModel.init(); + + return viewModel; + }; + this.getViewModelFormFund = function() { var webServiceClientFactory = new WebServiceClientFactory(); diff --git a/src/js/models/AblageType.js b/src/js/models/AblageType.js index fe2bc67..71e2fe4 100644 --- a/src/js/models/AblageType.js +++ b/src/js/models/AblageType.js @@ -1,4 +1,5 @@ function AblageType() { this.Bezeichnung = ""; + this.CountOfAblagen = 0; } \ No newline at end of file diff --git a/src/js/models/FundAttributType.js b/src/js/models/FundAttributType.js index fe2bc67..e5b778c 100644 --- a/src/js/models/FundAttributType.js +++ b/src/js/models/FundAttributType.js @@ -1,4 +1,5 @@ -function AblageType() +function FundAttributType() { this.Bezeichnung = ""; + this.CountOfFundAttributen = 0; } \ No newline at end of file diff --git a/src/js/models/OrtType.js b/src/js/models/OrtType.js index 843d01d..088fc29 100644 --- a/src/js/models/OrtType.js +++ b/src/js/models/OrtType.js @@ -1,4 +1,5 @@ function OrtType() { this.Bezeichnung = ""; + this.CountOfOrten = 0; } \ No newline at end of file diff --git a/src/js/page.js b/src/js/page.js index fa59e40..58d3155 100644 --- a/src/js/page.js +++ b/src/js/page.js @@ -69,5 +69,5 @@ function getFormMode() function openFormNewElement() { - window.open(window.location.href.replace(window.location.search, "")); + window.open(window.location.href.replace(window.location.search, ""), "_self"); } \ No newline at end of file diff --git a/src/js/viewModels/ViewModelFormAblageType.js b/src/js/viewModels/ViewModelFormAblageType.js index 79e1ec6..b2d458f 100644 --- a/src/js/viewModels/ViewModelFormAblageType.js +++ b/src/js/viewModels/ViewModelFormAblageType.js @@ -8,13 +8,15 @@ var ViewModelFormAblageType = function (webServiceClient) { this._createPropertyListeners = function () { return { id: new Array(), - bezeichnung: new Array() + bezeichnung: new Array(), + countOfAblagen: new Array() }; }; this._updateAllPropertyListeners = function () { this._update("id", this._model.Id); this._update("bezeichnung", this._model.Bezeichnung); + this._update("countOfAblagen", this._model.CountOfAblagen); }; //#region properties @@ -24,10 +26,17 @@ var ViewModelFormAblageType = function (webServiceClient) { }; this.setBezeichnung = function (bezeichnung) { + console.log("'Bezeichnung' changed to '" + bezeichnung + "'"); this._model.Bezeichnung = bezeichnung; this._update("dataChanged"); }; //#endregion + + //#region Anzahl von Ablagen + this.getCountOfAblagen = function () { + return this._model.CountOfAblagen; + }; + //#endregion //#endregion //#region methods diff --git a/src/js/viewModels/ViewModelFormFundAttributType.js b/src/js/viewModels/ViewModelFormFundAttributType.js new file mode 100644 index 0000000..9000b3c --- /dev/null +++ b/src/js/viewModels/ViewModelFormFundAttributType.js @@ -0,0 +1,46 @@ +var ViewModelFormFundAttributType = function (webServiceClient) { + this._webServiceClient = webServiceClient; + + this._createModel = function () { + return new FundAttributType(); + }; + + this._createPropertyListeners = function () { + return { + id: new Array(), + bezeichnung: new Array(), + countOfFundAttributen: new Array() + }; + }; + + this._updateAllPropertyListeners = function () { + this._update("id", this._model.Id); + this._update("bezeichnung", this._model.Bezeichnung); + this._update("countOfFundAttributen", this._model.CountOfFundAttributen); + }; + + //#region properties + //#region Bezeichnung + this.getBezeichnung = function () { + return this._model.Bezeichnung; + }; + + this.setBezeichnung = function (bezeichnung) { + console.log("'Bezeichnung' changed to '" + bezeichnung + "'"); + this._model.Bezeichnung = bezeichnung; + this._update("dataChanged"); + }; + //#endregion + + //#region Anzahl von Fundattributen + this.getCountOfFundAttributen = function () { + return this._model.CountOfFundAttributen; + }; + //#endregion + //#endregion + + //#region methods + //#endregion +}; + +ViewModelFormFundAttributType.prototype = new ViewModelForm(); \ No newline at end of file diff --git a/src/js/viewModels/ViewModelFormOrtType.js b/src/js/viewModels/ViewModelFormOrtType.js new file mode 100644 index 0000000..7ce7364 --- /dev/null +++ b/src/js/viewModels/ViewModelFormOrtType.js @@ -0,0 +1,46 @@ +var ViewModelFormOrtType = function (webServiceClient) { + this._webServiceClient = webServiceClient; + + this._createModel = function () { + return new OrtType(); + }; + + this._createPropertyListeners = function () { + return { + id: new Array(), + bezeichnung: new Array(), + countOfOrten: new Array() + }; + }; + + this._updateAllPropertyListeners = function () { + this._update("id", this._model.Id); + this._update("bezeichnung", this._model.Bezeichnung); + this._update("countOfOrten", this._model.CountOfOrten); + }; + + //#region properties + //#region Bezeichnung + this.getBezeichnung = function () { + return this._model.Bezeichnung; + }; + + this.setBezeichnung = function (bezeichnung) { + console.log("'Bezeichnung' changed to '" + bezeichnung + "'"); + this._model.Bezeichnung = bezeichnung; + this._update("dataChanged"); + }; + //#endregion + + //#region Anzahl von Orten + this.getCountOfOrten = function () { + return this._model.CountOfOrten; + }; + //#endregion + //#endregion + + //#region methods + //#endregion +}; + +ViewModelFormOrtType.prototype = new ViewModelForm(); \ No newline at end of file diff --git a/src/js/viewModels/ViewModelList.js b/src/js/viewModels/ViewModelList.js index c5e4439..aa5c426 100644 --- a/src/js/viewModels/ViewModelList.js +++ b/src/js/viewModels/ViewModelList.js @@ -1,13 +1,16 @@ var ViewModelList = function (webServiceClient) { //#region variables this._models = new Array(); + this._selectedItem = null; this._webServiceClient = webServiceClient; this._listeners = { loadAll: new Array(), create: new Array(), save: new Array(), delete: new Array(), - dataChanged: new Array() + dataChanged: new Array(), + itemSelected : new Array(), + selectionCleared : new Array() }; //#endregion @@ -30,6 +33,58 @@ var ViewModelList = function (webServiceClient) { }; //#endregion + /** + * Gets the selected item. + * @public + */ + this.getSelectedItem = function () { + return this._selectedItem; + }; + + /** + * Clears the selection of an item. + * @public + */ + this.clearSelection = function () { + this._selectedItem = null; + this._update("selectionCleared"); + }; + + /** + * Sets the given item as selected. If the item is already selected it becomes unselected. + * @param {model} item The item that is to be set as selected. + * @public + */ + this.selectItem = function (item) { + if (item == undefined || + item == null) { + console.log("ERROR: Item to be set as selected is not set!"); + this._update("selectionCleared"); + return; + } + + if (this._selectedItem != null && + item.Id == this._selectedItem.Id) + { + console.log("DEBUG: The selected item is already selected. Selection will be cleared."); + this.clearSelection(); + return; + } + + for (var i = 0; i < this._models.length; i++) { + if (this._models[i].Id == item.Id) { + console.log("DEBUG: Item to be set as selected is in the list."); + this._selectedItem = this._models[i]; + var args = { + SelectedItem : this._selectedItem, + Index : i + }; + this._update("itemSelected", args); + break; + } + } + }; + //#region observer methods /** * Registers this instance as listener to the events offered by the WebServiceClient. @@ -72,6 +127,7 @@ var ViewModelList = function (webServiceClient) { this._loadAllElements = function(elements) { this._models = elements; this._update("dataChanged", this._models); + this.clearSelection(); this._update("loadAll", this._models); } @@ -96,6 +152,7 @@ var ViewModelList = function (webServiceClient) { } this._update("dataChanged", this._models); + this.clearSelection(); this._update("create", element); }; @@ -111,6 +168,7 @@ var ViewModelList = function (webServiceClient) { } this._update("dataChanged", this._models); + this.clearSelection(); this._update("save", element); }; @@ -126,6 +184,7 @@ var ViewModelList = function (webServiceClient) { } this._update("dataChanged", this._models); + this.clearSelection(); this._update("delete", element); }; @@ -138,31 +197,24 @@ var ViewModelList = function (webServiceClient) { this.Fail = function (messages, listener) { switch (listener) { case "loadAll": { - this._failLoadAll(messages); + this._update("dataChanged", this._models); + this._fail("loadAll", messages); break; } case "create": { - this._update("dataChanged", this._models); this._fail("create", messages); break; } case "save": { - this._update("dataChanged", this._models); this._fail("save", messages); break; } case "delete": { - this._update("dataChanged", this._models); this._fail("delete", messages); break; } } }; - - this._failLoadAll = function (messages) { - this._update("dataChanged", this._models); - this._fail("loadAll", messages); - }; //#endregion //#region observable subject methods diff --git a/src/js/views/AblageType/Form.js b/src/js/views/AblageType/Form.js index 02c508c..f650a55 100644 --- a/src/js/views/AblageType/Form.js +++ b/src/js/views/AblageType/Form.js @@ -1,94 +1,60 @@ -var _viewModelListAblageType = null; +var _viewModelFormAblageType = null; $(document).ready(function () { var viewModelFactory = new ViewModelFactory(); - _viewModelListAblageType = viewModelFactory.getViewModelListAblageType(); + _viewModelFormAblageType = viewModelFactory.getViewModelFormAblageType(); - RegisterToViewModel(); + InitStatusChanged(); + InitDataChanged(); InitBreadcrumb(); - InitGrid(); + InitButtonNew(); + InitButtonSave(); + InitButtonDelete(); + InitButtonUndo(); + InitButtonToList(); - _viewModelListAblageType.loadAll(); -}); + InitFieldId(); + InitFieldBezeichnung(); + InitFieldCountOfAblagen(); -function InitBreadcrumb() -{ - $("#breadcrumb").Breadcrumb({ - PageName : "AblageTypeManagement" - }); -} + if (getUrlParameterValue("Id")) { + _viewModelFormAblageType.load(getUrlParameterValue("Id")); + } + else { + _viewModelFormAblageType.updateAllListeners(); + } +}); -function RegisterToViewModel() { - _viewModelListAblageType.register("dataChanged", new GuiClient(UpdateGridData, UpdateGridData)); - _viewModelListAblageType.register("loadAll", new GuiClient(showMessageAllLoaded, showErrorMessages)); - _viewModelListAblageType.register("create", new GuiClient(showMessageCreated, showErrorMessages)); - _viewModelListAblageType.register("save", new GuiClient(showMessageSaved, showErrorMessages)); - _viewModelListAblageType.register("delete", new GuiClient(showMessageDeleted, showErrorMessages)); +function InitStatusChanged() { + _viewModelFormAblageType.register("load", new GuiClient(showMessageLoaded, showErrorMessages)); + _viewModelFormAblageType.register("create", new GuiClient(showMessageCreated, showErrorMessages)); + _viewModelFormAblageType.register("save", new GuiClient(showMessageSaved, showErrorMessages)); + _viewModelFormAblageType.register("delete", new GuiClient(showMessageDeleted, showErrorMessages)); } -function InitGrid() -{ - jsGrid.locale("de"); - ShowAblageTypes(); - UpdateGridData(new Array()); +function InitDataChanged() { + _viewModelFormAblageType.register("dataChanged", new GuiClient(EnableButtonUndo, showErrorMessages)); } -function UpdateGridData(ablageTypes) { - $("#gridContainer").jsGrid({ - data: JSON.parse(JSON.stringify(ablageTypes)) - }); -} - -function ShowAblageTypes() +function InitBreadcrumb() { - $("#gridContainer").jsGrid({ - width: "100%", - - inserting: true, - editing: true, - sorting: false, - paging: false, - autoload: false, - - controller: { - insertItem: function(item) { - _viewModelListAblageType.create(item); - }, - insertModeButtonTooltip: "Neu", - updateItem: function(item) { - _viewModelListAblageType.save(item); - }, - editButtonTooltip: "Bearbeiten", - deleteItem: function(item) { - _viewModelListAblageType.delete(item); - }, - deleteButtonTooltip: "Löschen" - }, - - fields: [ - { - name: "Bezeichnung", - type: "text", - validate: "required" - }, - { - title: "Anzahl von Ablagen", - name: "CountOfAblagen", - type: "number", - inserting: false, - editing: false - }, - { - type: "control" - } - ] - }); + if (getFormMode() == "create") { + $("#breadcrumb").Breadcrumb({ + PageName: "AblageTypeFormNew" + }); + } + else if (getFormMode() == "edit") { + $("#breadcrumb").Breadcrumb({ + PageName: "AblageTypeFormEdit" + }); + } } -function showMessageAllLoaded(elements) { +//#region messages +function showMessageLoaded(element) { $.toast({ heading: "Information", - text: elements.length + " Ablagetypen geladen", + text: "Ablagetyp \"" + element.Bezeichnung + "\" geladen", icon: "info" }); } @@ -115,4 +81,177 @@ function showMessageDeleted(element) { text: "Ablagetyp \"" + element.Bezeichnung + "\" gelöscht", icon: "success" }); -} \ No newline at end of file +} +//#endregion + +//#region form fields + +//#region Id +function InitFieldId() { + _viewModelFormAblageType.register("id", new GuiClient(setId, showErrorMessages)); +} + +function setId(id) { + if (id == null) { + document.title = "Ablagetyp"; + DisableButtonDelete(); + } + else { + document.title = "Ablagetyp: (" + id + ")"; + EnableButtonDelete(); + } +} +//#endregion + +//#region Bezeichnung +function InitFieldBezeichnung() { + _viewModelFormAblageType.register("bezeichnung", new GuiClient(setBezeichnung, showMessagesBezeichnung)); + $("#textboxBezeichnung").change(function () { + _viewModelFormAblageType.setBezeichnung($("#textboxBezeichnung").val()) + }); +} + +function setBezeichnung(bezeichnung) { + console.log("setting value of 'Bezeichnung' to " + bezeichnung); + $("#textboxBezeichnung").val(bezeichnung); +} + +function showMessagesBezeichnung(messages) { + $("#divBezeichnung .fieldValue div[name=messages]").text(messages); +} +//#endregion + +//#region Anzahl von Ablagen +function InitFieldCountOfAblagen() { + _viewModelFormAblageType.register("countOfAblagen", new GuiClient(setCountOfAblagen, null)); +} + +function setCountOfAblagen(countOfAblagen) { + console.log("setting value of 'count of Ablagen' to " + countOfAblagen); + $("#labelCountOfAblagen").text(countOfAblagen); +} +//#endregion +//#endregion + +//#region form actions +//#region new +function InitButtonNew() { + EnableButtonNew(); + $("#buttonNew").click(openFormNewElement); +} + +function EnableButtonNew() { + $("#buttonNew").removeClass("disabled"); + $("#buttonNew").prop("disabled", false); +} + +function DisableButtonNew() { + $("#buttonNew").addClass("disabled"); + $("#buttonNew").prop("disabled", true); +} +//#endregion + +//#region save +function InitButtonSave() { + EnableButtonSave(); + $("#buttonSave").click(function () { _viewModelFormAblageType.save(); }); +} + +function EnableButtonSave() { + $("#buttonSave").removeClass("disabled"); + $("#buttonSave").prop("disabled", false); +} + +function DisableButtonSave() { + $("#buttonSave").addClass("disabled"); + $("#buttonSave").prop("disabled", true); +} +//#endregion + +//#region delete +function InitButtonDelete() { + DisableButtonDelete(); + $("#buttonDelete").click(ShowDialogDelete); +} + +function EnableButtonDelete() { + $("#buttonDelete").removeClass("disabled"); + $("#buttonDelete").prop("disabled", false); +} + +function DisableButtonDelete() { + $("#buttonDelete").addClass("disabled"); + $("#buttonDelete").prop("disabled", true); +} + +function ShowDialogDelete() { + $("#dialogDelete").empty(); + $("#dialogDelete").append( + $("

").append("Möchten Sie diesen Ablagetyp löschen?") + ); + $("#dialogDelete").dialog({ + height: "auto", + width: 750, + modal: true, + buttons: { + "Löschen": function () { + _viewModelFormAblageType.delete(); + + $(this).dialog("close"); + }, + "Abbrechen": function () { + $(this).dialog("close"); + } + } + }); + + $("#DialogDelete").dialog("open"); +} +//#endregion + +//#region undo +function InitButtonUndo() { + DisableButtonUndo(); + _viewModelFormAblageType.register("dataResetted", new GuiClient(DisableButtonUndo, showErrorMessages)); + _viewModelFormAblageType.register("dataResetted", new GuiClient(ResetPropertiesMessages, showErrorMessages)); + $("#buttonUndo").click(function () { + console.log("button 'undo' clicked"); + _viewModelFormAblageType.undoAllChanges(); + }); +} + +function EnableButtonUndo() { + $("#buttonUndo").removeClass("disabled"); + $("#buttonUndo").prop("disabled", false); +} + +function DisableButtonUndo() { + $("#buttonUndo").addClass("disabled"); + $("#buttonUndo").prop("disabled", true); +} + +function ResetPropertiesMessages() { + $(".fieldValue div[name=messages]").empty(); +} +//#endregion + +//#region open list +function InitButtonToList() { + EnableButtonToList(); + $("#buttonToList").click( function() { + console.log("button 'to list' clicked"); + window.open("/Munins Archiv/src/AblageType/List.html", "_self"); + }); +} + +function EnableButtonToList() { + $("#buttonToList").removeClass("disabled"); + $("#buttonToList").prop("disabled", false); +} + +function DisableButtonToList() { + $("#buttonToList").addClass("disabled"); + $("#buttonToList").prop("disabled", true); +} +//#endregion +//#endregion \ No newline at end of file diff --git a/src/js/views/AblageType/List.js b/src/js/views/AblageType/List.js new file mode 100644 index 0000000..64ce542 --- /dev/null +++ b/src/js/views/AblageType/List.js @@ -0,0 +1,253 @@ +var _viewModelListAblageType = null; + +$(document).ready(function () { + var viewModelFactory = new ViewModelFactory(); + _viewModelListAblageType = viewModelFactory.getViewModelListAblageType(); + + RegisterToViewModel(); + InitBreadcrumb(); + InitButtonNew(); + InitButtonEdit(); + InitButtonDelete(); + InitButtonReload(); + + InitGrid(); + + _viewModelListAblageType.loadAll(); +}); + +function InitBreadcrumb() +{ + $("#breadcrumb").Breadcrumb({ + PageName : "AblageTypeList" + }); +} + +function RegisterToViewModel() { + _viewModelListAblageType.register("dataChanged", new GuiClient(UpdateGridData, UpdateGridData)); + _viewModelListAblageType.register("loadAll", new GuiClient(showMessageAllLoaded, showErrorMessages)); + _viewModelListAblageType.register("create", new GuiClient(showMessageCreated, showErrorMessages)); + _viewModelListAblageType.register("delete", new GuiClient(showMessageDeleted, showErrorMessages)); + _viewModelListAblageType.register("itemSelected", new GuiClient(markSelectedItem, showErrorMessages)); + _viewModelListAblageType.register("itemSelected", new GuiClient(EnableButtonEdit, null)); + _viewModelListAblageType.register("itemSelected", new GuiClient(EnableButtonDelete, null)); + _viewModelListAblageType.register("selectionCleared", new GuiClient(clearSelectedItemHighlighting, null)); + _viewModelListAblageType.register("selectionCleared", new GuiClient(DisableButtonEdit, null)); + _viewModelListAblageType.register("selectionCleared", new GuiClient(DisableButtonDelete, null)); +} + +function clearSelectedItemHighlighting() { + $(".jsgrid-row, .jsgrid-alt-row").each(function(index){ + console.log("DEBUG: Removing css class from:") + console.log($(this)); + $(this).removeClass("selectedRow"); + }); +} + +function markSelectedItem(selectedItemArgs) { + clearSelectedItemHighlighting(); + + if (selectedItemArgs == undefined || + selectedItemArgs == null || + selectedItemArgs.Index == undefined) + { + console.log("ERROR: Setting selected item index is not set!") + return; + } + + console.log("DEBUG: Setting selected item:") + console.log(selectedItemArgs); + + var row = $(".jsgrid-row, .jsgrid-alt-row").eq(selectedItemArgs.Index) + + console.log("DEBUG: Selected row:"); + console.log(row); + + row.addClass("selectedRow"); +} + +function InitGrid() +{ + jsGrid.locale("de"); + ShowAblageTypes(); + UpdateGridData(new Array()); +} + +function UpdateGridData(ablageTypes) { + $("#gridContainer").jsGrid({ + data: JSON.parse(JSON.stringify(ablageTypes)) + }); +} + +function ShowAblageTypes() +{ + $("#gridContainer").jsGrid({ + width: "100%", + + inserting: false, + editing: false, + sorting: true, + paging: false, + autoload: false, + + fields: [ + { + name: "Bezeichnung", + type: "text", + validate: "required" + }, + { + title: "Anzahl von Ablagen", + name: "CountOfAblagen", + type: "number", + inserting: false, + editing: false + } + ], + + rowClick: function(args) { + console.log("DEBUG: Selected element:"); + console.log(args.item); + _viewModelListAblageType.selectItem(args.item); + } + }); +} + +function setIdToEditLink(id) { + $("#buttonEdit").attr("href", "/Munins Archiv/src/AblageType/Form.html?Id=" + id); +} + +function showMessageAllLoaded(elements) { + $.toast({ + heading: "Information", + text: elements.length + " Ablagetypen geladen", + icon: "info" + }); +} + +function showMessageCreated(element) { + $.toast({ + heading: "Information", + text: "Ablagetyp \"" + element.Bezeichnung + "\" erzeugt", + icon: "success" + }); +} + +function showMessageSaved(element) { + $.toast({ + heading: "Information", + text: "Ablagetyp \"" + element.Bezeichnung + "\" gespeichert", + icon: "success" + }); +} + +function showMessageDeleted(element) { + $.toast({ + heading: "Information", + text: "Ablagetyp \"" + element.Bezeichnung + "\" gelöscht", + icon: "success" + }); +} + +//#region form actions +//#region new +function InitButtonNew() { + EnableButtonNew(); + $("#buttonNew").click(function () { + console.log("button 'new' clicked"); + window.open("/Munins Archiv/src/AblageType/Form.html", "_self"); + }); +} + +function EnableButtonNew() { + $("#buttonNew").removeClass("disabled"); + $("#buttonNew").prop("disabled", false); +} + +function DisableButtonNew() { + $("#buttonNew").addClass("disabled"); + $("#buttonNew").prop("disabled", true); +} +//#endregion + +//#region edit +function InitButtonEdit() { + DisableButtonEdit(); + $("#buttonEdit").click(function () { + console.log("button 'edit' clicked"); + window.open("/Munins Archiv/src/AblageType/Form.html?Id=" + _viewModelListAblageType.getSelectedItem().Id, "_self"); + }); +} + +function EnableButtonEdit() { + $("#buttonEdit").removeClass("disabled"); + $("#buttonEdit").prop("disabled", false); +} + +function DisableButtonEdit() { + $("#buttonEdit").addClass("disabled"); + $("#buttonEdit").prop("disabled", true); +} +//#endregion + +//#region delete +function InitButtonDelete() { + DisableButtonDelete(); + $("#buttonDelete").click(ShowDialogDelete); +} + +function EnableButtonDelete() { + $("#buttonDelete").removeClass("disabled"); + $("#buttonDelete").prop("disabled", false); +} + +function DisableButtonDelete() { + $("#buttonDelete").addClass("disabled"); + $("#buttonDelete").prop("disabled", true); +} + +function ShowDialogDelete() { + $("#dialogDelete").empty(); + $("#dialogDelete").append( + $("

").append("Möchten Sie den Ablagetyp \"" + _viewModelListAblageType.getSelectedItem().Bezeichnung + "\" löschen?") + ); + $("#dialogDelete").dialog({ + height: "auto", + width: 750, + modal: true, + buttons: { + "Löschen": function () { + _viewModelListAblageType.delete(_viewModelListAblageType.getSelectedItem()); + + $(this).dialog("close"); + }, + "Abbrechen": function () { + $(this).dialog("close"); + } + } + }); + + $("#DialogDelete").dialog("open"); +} +//#endregion + +//#region reload +function InitButtonReload() { + EnableButtonReload(); + $("#buttonReload").click(function () { + console.log("button 'reload' clicked"); + _viewModelListAblageType.loadAll(); + }); +} + +function EnableButtonReload() { + $("#buttonReload").removeClass("disabled"); + $("#buttonReload").prop("disabled", false); +} + +function DisableButtonReload() { + $("#buttonReload").addClass("disabled"); + $("#buttonReload").prop("disabled", true); +} +//#endregion +//#endregion \ No newline at end of file diff --git a/src/js/views/Fund/Form.js b/src/js/views/Fund/Form.js index 46d773b..4016ca8 100644 --- a/src/js/views/Fund/Form.js +++ b/src/js/views/Fund/Form.js @@ -148,7 +148,7 @@ function EnableButtonUndo() { } function DisableButtonUndo() { - $("#buttonUndo").removeClass("disabled"); + $("#buttonUndo").addClass("disabled"); $("#buttonUndo").prop("disabled", true); } diff --git a/src/js/views/FundAttributType/Form.js b/src/js/views/FundAttributType/Form.js index e34ae9f..aec2026 100644 --- a/src/js/views/FundAttributType/Form.js +++ b/src/js/views/FundAttributType/Form.js @@ -1,94 +1,60 @@ -var _viewModelListFundAttributType = null; +var _viewModelFormFundAttributType = null; $(document).ready(function () { var viewModelFactory = new ViewModelFactory(); - _viewModelListFundAttributType = viewModelFactory.getViewModelListFundAttributType(); + _viewModelFormFundAttributType = viewModelFactory.getViewModelFormFundAttributType(); - RegisterToViewModel(); + InitStatusChanged(); + InitDataChanged(); InitBreadcrumb(); - InitGrid(); + InitButtonNew(); + InitButtonSave(); + InitButtonDelete(); + InitButtonUndo(); + InitButtonToList(); - _viewModelListFundAttributType.loadAll(); -}); + InitFieldId(); + InitFieldBezeichnung(); + InitFieldCountOfFundAttribute(); -function InitBreadcrumb() -{ - $("#breadcrumb").Breadcrumb({ - PageName : "FundAttributTypeManagement" - }); -} + if (getUrlParameterValue("Id")) { + _viewModelFormFundAttributType.load(getUrlParameterValue("Id")); + } + else { + _viewModelFormFundAttributType.updateAllListeners(); + } +}); -function RegisterToViewModel() { - _viewModelListFundAttributType.register("dataChanged", new GuiClient(UpdateGridData, UpdateGridData)); - _viewModelListFundAttributType.register("loadAll", new GuiClient(showMessageAllLoaded, showErrorMessages)); - _viewModelListFundAttributType.register("create", new GuiClient(showMessageCreated, showErrorMessages)); - _viewModelListFundAttributType.register("save", new GuiClient(showMessageSaved, showErrorMessages)); - _viewModelListFundAttributType.register("delete", new GuiClient(showMessageDeleted, showErrorMessages)); +function InitStatusChanged() { + _viewModelFormFundAttributType.register("load", new GuiClient(showMessageLoaded, showErrorMessages)); + _viewModelFormFundAttributType.register("create", new GuiClient(showMessageCreated, showErrorMessages)); + _viewModelFormFundAttributType.register("save", new GuiClient(showMessageSaved, showErrorMessages)); + _viewModelFormFundAttributType.register("delete", new GuiClient(showMessageDeleted, showErrorMessages)); } -function InitGrid() -{ - jsGrid.locale("de"); - ShowFundAttributTypes(); - UpdateGridData(new Array()); +function InitDataChanged() { + _viewModelFormFundAttributType.register("dataChanged", new GuiClient(EnableButtonUndo, showErrorMessages)); } -function UpdateGridData(ortTypes) { - $("#gridContainer").jsGrid({ - data: JSON.parse(JSON.stringify(ortTypes)) - }); -} - -function ShowFundAttributTypes() +function InitBreadcrumb() { - $("#gridContainer").jsGrid({ - width: "100%", - - inserting: true, - editing: true, - sorting: false, - paging: false, - autoload: false, - - controller: { - insertItem: function(item) { - _viewModelListFundAttributType.create(item); - }, - insertModeButtonTooltip: "Neu", - updateItem: function(item) { - _viewModelListFundAttributType.save(item); - }, - editButtonTooltip: "Bearbeiten", - deleteItem: function(item) { - _viewModelListFundAttributType.delete(item); - }, - deleteButtonTooltip: "Löschen" - }, - - fields: [ - { - name: "Bezeichnung", - type: "text", - validate: "required" - }, - { - title: "Anzahl von Fundattributen", - name: "CountOfFundAttributen", - type: "number", - inserting: false, - editing: false - }, - { - type: "control" - } - ] - }); + if (getFormMode() == "create") { + $("#breadcrumb").Breadcrumb({ + PageName: "FundAttributTypeFormNew" + }); + } + else if (getFormMode() == "edit") { + $("#breadcrumb").Breadcrumb({ + PageName: "FundAttributTypeFormEdit" + }); + } } -function showMessageAllLoaded(elements) { +//#region messages +function showMessageLoaded(element) { $.toast({ heading: "Information", - text: elements.length + " Fundattributtypen geladen", + text: "Fundattributtyp \"" + element.Bezeichnung + "\" geladen", icon: "info" }); } @@ -115,4 +81,177 @@ function showMessageDeleted(element) { text: "Fundattributtyp \"" + element.Bezeichnung + "\" gelöscht", icon: "success" }); -} \ No newline at end of file +} +//#endregion + +//#region form fields + +//#region Id +function InitFieldId() { + _viewModelFormFundAttributType.register("id", new GuiClient(setId, showErrorMessages)); +} + +function setId(id) { + if (id == null) { + document.title = "Fundattributtyp"; + DisableButtonDelete(); + } + else { + document.title = "Fundattributtyp: (" + id + ")"; + EnableButtonDelete(); + } +} +//#endregion + +//#region Bezeichnung +function InitFieldBezeichnung() { + _viewModelFormFundAttributType.register("bezeichnung", new GuiClient(setBezeichnung, showMessagesBezeichnung)); + $("#textboxBezeichnung").change(function () { + _viewModelFormFundAttributType.setBezeichnung($("#textboxBezeichnung").val()) + }); +} + +function setBezeichnung(bezeichnung) { + console.log("setting value of 'Bezeichnung' to " + bezeichnung); + $("#textboxBezeichnung").val(bezeichnung); +} + +function showMessagesBezeichnung(messages) { + $("#divBezeichnung .fieldValue div[name=messages]").text(messages); +} +//#endregion + +//#region Anzahl von Fundattributen +function InitFieldCountOfFundAttribute() { + _viewModelFormFundAttributType.register("countOfFundAttributen", new GuiClient(setCountOfFundAttributen, null)); +} + +function setCountOfFundAttributen(countOfFundAttributen) { + console.log("setting value of 'count of FundAttribute' to " + countOfFundAttributen); + $("#labelCountOfFundAttributen").text(countOfFundAttributen); +} +//#endregion +//#endregion + +//#region form actions +//#region new +function InitButtonNew() { + EnableButtonNew(); + $("#buttonNew").click(openFormNewElement); +} + +function EnableButtonNew() { + $("#buttonNew").removeClass("disabled"); + $("#buttonNew").prop("disabled", false); +} + +function DisableButtonNew() { + $("#buttonNew").addClass("disabled"); + $("#buttonNew").prop("disabled", true); +} +//#endregion + +//#region save +function InitButtonSave() { + EnableButtonSave(); + $("#buttonSave").click(function () { _viewModelFormFundAttributType.save(); }); +} + +function EnableButtonSave() { + $("#buttonSave").removeClass("disabled"); + $("#buttonSave").prop("disabled", false); +} + +function DisableButtonSave() { + $("#buttonSave").addClass("disabled"); + $("#buttonSave").prop("disabled", true); +} +//#endregion + +//#region delete +function InitButtonDelete() { + DisableButtonDelete(); + $("#buttonDelete").click(ShowDialogDelete); +} + +function EnableButtonDelete() { + $("#buttonDelete").removeClass("disabled"); + $("#buttonDelete").prop("disabled", false); +} + +function DisableButtonDelete() { + $("#buttonDelete").addClass("disabled"); + $("#buttonDelete").prop("disabled", true); +} + +function ShowDialogDelete() { + $("#dialogDelete").empty(); + $("#dialogDelete").append( + $("

").append("Möchten Sie diesen Fundattributtyp löschen?") + ); + $("#dialogDelete").dialog({ + height: "auto", + width: 750, + modal: true, + buttons: { + "Löschen": function () { + _viewModelFormFundAttributType.delete(); + + $(this).dialog("close"); + }, + "Abbrechen": function () { + $(this).dialog("close"); + } + } + }); + + $("#DialogDelete").dialog("open"); +} +//#endregion + +//#region undo +function InitButtonUndo() { + DisableButtonUndo(); + _viewModelFormFundAttributType.register("dataResetted", new GuiClient(DisableButtonUndo, showErrorMessages)); + _viewModelFormFundAttributType.register("dataResetted", new GuiClient(ResetPropertiesMessages, showErrorMessages)); + $("#buttonUndo").click(function () { + console.log("button 'undo' clicked"); + _viewModelFormFundAttributType.undoAllChanges(); + }); +} + +function EnableButtonUndo() { + $("#buttonUndo").removeClass("disabled"); + $("#buttonUndo").prop("disabled", false); +} + +function DisableButtonUndo() { + $("#buttonUndo").addClass("disabled"); + $("#buttonUndo").prop("disabled", true); +} + +function ResetPropertiesMessages() { + $(".fieldValue div[name=messages]").empty(); +} +//#endregion + +//#region open list +function InitButtonToList() { + EnableButtonToList(); + $("#buttonToList").click( function() { + console.log("button 'to list' clicked"); + window.open("/Munins Archiv/src/FundAttributType/List.html", "_self"); + }); +} + +function EnableButtonToList() { + $("#buttonToList").removeClass("disabled"); + $("#buttonToList").prop("disabled", false); +} + +function DisableButtonToList() { + $("#buttonToList").addClass("disabled"); + $("#buttonToList").prop("disabled", true); +} +//#endregion +//#endregion \ No newline at end of file diff --git a/src/js/views/FundAttributType/List.js b/src/js/views/FundAttributType/List.js new file mode 100644 index 0000000..2e3ed5d --- /dev/null +++ b/src/js/views/FundAttributType/List.js @@ -0,0 +1,253 @@ +var _viewModelListFundAttributType = null; + +$(document).ready(function () { + var viewModelFactory = new ViewModelFactory(); + _viewModelListFundAttributType = viewModelFactory.getViewModelListFundAttributType(); + + RegisterToViewModel(); + InitBreadcrumb(); + InitButtonNew(); + InitButtonEdit(); + InitButtonDelete(); + InitButtonReload(); + + InitGrid(); + + _viewModelListFundAttributType.loadAll(); +}); + +function InitBreadcrumb() +{ + $("#breadcrumb").Breadcrumb({ + PageName : "FundAttributTypeList" + }); +} + +function RegisterToViewModel() { + _viewModelListFundAttributType.register("dataChanged", new GuiClient(UpdateGridData, UpdateGridData)); + _viewModelListFundAttributType.register("loadAll", new GuiClient(showMessageAllLoaded, showErrorMessages)); + _viewModelListFundAttributType.register("create", new GuiClient(showMessageCreated, showErrorMessages)); + _viewModelListFundAttributType.register("delete", new GuiClient(showMessageDeleted, showErrorMessages)); + _viewModelListFundAttributType.register("itemSelected", new GuiClient(markSelectedItem, showErrorMessages)); + _viewModelListFundAttributType.register("itemSelected", new GuiClient(EnableButtonEdit, null)); + _viewModelListFundAttributType.register("itemSelected", new GuiClient(EnableButtonDelete, null)); + _viewModelListFundAttributType.register("selectionCleared", new GuiClient(clearSelectedItemHighlighting, null)); + _viewModelListFundAttributType.register("selectionCleared", new GuiClient(DisableButtonEdit, null)); + _viewModelListFundAttributType.register("selectionCleared", new GuiClient(DisableButtonDelete, null)); +} + +function clearSelectedItemHighlighting() { + $(".jsgrid-row, .jsgrid-alt-row").each(function(index){ + console.log("DEBUG: Removing css class from:") + console.log($(this)); + $(this).removeClass("selectedRow"); + }); +} + +function markSelectedItem(selectedItemArgs) { + clearSelectedItemHighlighting(); + + if (selectedItemArgs == undefined || + selectedItemArgs == null || + selectedItemArgs.Index == undefined) + { + console.log("ERROR: Setting selected item index is not set!") + return; + } + + console.log("DEBUG: Setting selected item:") + console.log(selectedItemArgs); + + var row = $(".jsgrid-row, .jsgrid-alt-row").eq(selectedItemArgs.Index) + + console.log("DEBUG: Selected row:"); + console.log(row); + + row.addClass("selectedRow"); +} + +function InitGrid() +{ + jsGrid.locale("de"); + ShowFundAttributTypes(); + UpdateGridData(new Array()); +} + +function UpdateGridData(fundAttributTypes) { + $("#gridContainer").jsGrid({ + data: JSON.parse(JSON.stringify(fundAttributTypes)) + }); +} + +function ShowFundAttributTypes() +{ + $("#gridContainer").jsGrid({ + width: "100%", + + inserting: false, + editing: false, + sorting: true, + paging: false, + autoload: false, + + fields: [ + { + name: "Bezeichnung", + type: "text", + validate: "required" + }, + { + title: "Anzahl von Fundattributen", + name: "CountOfFundAttributen", + type: "number", + inserting: false, + editing: false + } + ], + + rowClick: function(args) { + console.log("DEBUG: Selected element:"); + console.log(args.item); + _viewModelListFundAttributType.selectItem(args.item); + } + }); +} + +function setIdToEditLink(id) { + $("#buttonEdit").attr("href", "/Munins Archiv/src/FundAttributType/Form.html?Id=" + id); +} + +function showMessageAllLoaded(elements) { + $.toast({ + heading: "Information", + text: elements.length + " Fundattributtypen geladen", + icon: "info" + }); +} + +function showMessageCreated(element) { + $.toast({ + heading: "Information", + text: "Fundattributtyp \"" + element.Bezeichnung + "\" erzeugt", + icon: "success" + }); +} + +function showMessageSaved(element) { + $.toast({ + heading: "Information", + text: "Fundattributtyp \"" + element.Bezeichnung + "\" gespeichert", + icon: "success" + }); +} + +function showMessageDeleted(element) { + $.toast({ + heading: "Information", + text: "Fundattributtyp \"" + element.Bezeichnung + "\" gelöscht", + icon: "success" + }); +} + +//#region form actions +//#region new +function InitButtonNew() { + EnableButtonNew(); + $("#buttonNew").click(function () { + console.log("button 'new' clicked"); + window.open("/Munins Archiv/src/FundAttributType/Form.html", "_self"); + }); +} + +function EnableButtonNew() { + $("#buttonNew").removeClass("disabled"); + $("#buttonNew").prop("disabled", false); +} + +function DisableButtonNew() { + $("#buttonNew").addClass("disabled"); + $("#buttonNew").prop("disabled", true); +} +//#endregion + +//#region edit +function InitButtonEdit() { + DisableButtonEdit(); + $("#buttonEdit").click(function () { + console.log("button 'edit' clicked"); + window.open("/Munins Archiv/src/FundAttributType/Form.html?Id=" + _viewModelListFundAttributType.getSelectedItem().Id, "_self"); + }); +} + +function EnableButtonEdit() { + $("#buttonEdit").removeClass("disabled"); + $("#buttonEdit").prop("disabled", false); +} + +function DisableButtonEdit() { + $("#buttonEdit").addClass("disabled"); + $("#buttonEdit").prop("disabled", true); +} +//#endregion + +//#region delete +function InitButtonDelete() { + DisableButtonDelete(); + $("#buttonDelete").click(ShowDialogDelete); +} + +function EnableButtonDelete() { + $("#buttonDelete").removeClass("disabled"); + $("#buttonDelete").prop("disabled", false); +} + +function DisableButtonDelete() { + $("#buttonDelete").addClass("disabled"); + $("#buttonDelete").prop("disabled", true); +} + +function ShowDialogDelete() { + $("#dialogDelete").empty(); + $("#dialogDelete").append( + $("

").append("Möchten Sie den FundAttributtyp \"" + _viewModelListFundAttributType.getSelectedItem().Bezeichnung + "\" löschen?") + ); + $("#dialogDelete").dialog({ + height: "auto", + width: 750, + modal: true, + buttons: { + "Löschen": function () { + _viewModelListFundAttributType.delete(_viewModelListFundAttributType.getSelectedItem()); + + $(this).dialog("close"); + }, + "Abbrechen": function () { + $(this).dialog("close"); + } + } + }); + + $("#DialogDelete").dialog("open"); +} +//#endregion + +//#region reload +function InitButtonReload() { + EnableButtonReload(); + $("#buttonReload").click(function () { + console.log("button 'reload' clicked"); + _viewModelListFundAttributType.loadAll(); + }); +} + +function EnableButtonReload() { + $("#buttonReload").removeClass("disabled"); + $("#buttonReload").prop("disabled", false); +} + +function DisableButtonReload() { + $("#buttonReload").addClass("disabled"); + $("#buttonReload").prop("disabled", true); +} +//#endregion +//#endregion \ No newline at end of file diff --git a/src/js/views/OrtType/Form.js b/src/js/views/OrtType/Form.js index 0e8dbeb..211cb4c 100644 --- a/src/js/views/OrtType/Form.js +++ b/src/js/views/OrtType/Form.js @@ -1,94 +1,60 @@ -var _viewModelListOrtType = null; +var _viewModelFormOrtType = null; $(document).ready(function () { var viewModelFactory = new ViewModelFactory(); - _viewModelListOrtType = viewModelFactory.getViewModelListOrtType(); + _viewModelFormOrtType = viewModelFactory.getViewModelFormOrtType(); - RegisterToViewModel(); + InitStatusChanged(); + InitDataChanged(); InitBreadcrumb(); - InitGrid(); + InitButtonNew(); + InitButtonSave(); + InitButtonDelete(); + InitButtonUndo(); + InitButtonToList(); - _viewModelListOrtType.loadAll(); -}); + InitFieldId(); + InitFieldBezeichnung(); + InitFieldCountOfOrten(); -function InitBreadcrumb() -{ - $("#breadcrumb").Breadcrumb({ - PageName : "OrtTypeManagement" - }); -} + if (getUrlParameterValue("Id")) { + _viewModelFormOrtType.load(getUrlParameterValue("Id")); + } + else { + _viewModelFormOrtType.updateAllListeners(); + } +}); -function RegisterToViewModel() { - _viewModelListOrtType.register("dataChanged", new GuiClient(UpdateGridData, UpdateGridData)); - _viewModelListOrtType.register("loadAll", new GuiClient(showMessageAllLoaded, showErrorMessages)); - _viewModelListOrtType.register("create", new GuiClient(showMessageCreated, showErrorMessages)); - _viewModelListOrtType.register("save", new GuiClient(showMessageSaved, showErrorMessages)); - _viewModelListOrtType.register("delete", new GuiClient(showMessageDeleted, showErrorMessages)); +function InitStatusChanged() { + _viewModelFormOrtType.register("load", new GuiClient(showMessageLoaded, showErrorMessages)); + _viewModelFormOrtType.register("create", new GuiClient(showMessageCreated, showErrorMessages)); + _viewModelFormOrtType.register("save", new GuiClient(showMessageSaved, showErrorMessages)); + _viewModelFormOrtType.register("delete", new GuiClient(showMessageDeleted, showErrorMessages)); } -function InitGrid() -{ - jsGrid.locale("de"); - ShowOrtTypes(); - UpdateGridData(new Array()); +function InitDataChanged() { + _viewModelFormOrtType.register("dataChanged", new GuiClient(EnableButtonUndo, showErrorMessages)); } -function UpdateGridData(ortTypes) { - $("#gridContainer").jsGrid({ - data: JSON.parse(JSON.stringify(ortTypes)) - }); -} - -function ShowOrtTypes() +function InitBreadcrumb() { - $("#gridContainer").jsGrid({ - width: "100%", - - inserting: true, - editing: true, - sorting: false, - paging: false, - autoload: false, - - controller: { - insertItem: function(item) { - _viewModelListOrtType.create(item); - }, - insertModeButtonTooltip: "Neu", - updateItem: function(item) { - _viewModelListOrtType.save(item); - }, - editButtonTooltip: "Bearbeiten", - deleteItem: function(item) { - _viewModelListOrtType.delete(item); - }, - deleteButtonTooltip: "Löschen" - }, - - fields: [ - { - name: "Bezeichnung", - type: "text", - validate: "required" - }, - { - title: "Anzahl von Orten", - name: "CountOfOrten", - type: "number", - inserting: false, - editing: false - }, - { - type: "control" - } - ] - }); + if (getFormMode() == "create") { + $("#breadcrumb").Breadcrumb({ + PageName: "OrtTypeFormNew" + }); + } + else if (getFormMode() == "edit") { + $("#breadcrumb").Breadcrumb({ + PageName: "OrtTypeFormEdit" + }); + } } -function showMessageAllLoaded(elements) { +//#region messages +function showMessageLoaded(element) { $.toast({ heading: "Information", - text: elements.length + " Ortstypen geladen", + text: "Ortstyp \"" + element.Bezeichnung + "\" geladen", icon: "info" }); } @@ -115,4 +81,177 @@ function showMessageDeleted(element) { text: "Ortstyp \"" + element.Bezeichnung + "\" gelöscht", icon: "success" }); -} \ No newline at end of file +} +//#endregion + +//#region form fields + +//#region Id +function InitFieldId() { + _viewModelFormOrtType.register("id", new GuiClient(setId, showErrorMessages)); +} + +function setId(id) { + if (id == null) { + document.title = "Ortstyp"; + DisableButtonDelete(); + } + else { + document.title = "Ortstyp: (" + id + ")"; + EnableButtonDelete(); + } +} +//#endregion + +//#region Bezeichnung +function InitFieldBezeichnung() { + _viewModelFormOrtType.register("bezeichnung", new GuiClient(setBezeichnung, showMessagesBezeichnung)); + $("#textboxBezeichnung").change(function () { + _viewModelFormOrtType.setBezeichnung($("#textboxBezeichnung").val()) + }); +} + +function setBezeichnung(bezeichnung) { + console.log("setting value of 'Bezeichnung' to " + bezeichnung); + $("#textboxBezeichnung").val(bezeichnung); +} + +function showMessagesBezeichnung(messages) { + $("#divBezeichnung .fieldValue div[name=messages]").text(messages); +} +//#endregion + +//#region Anzahl von Orten +function InitFieldCountOfOrten() { + _viewModelFormOrtType.register("countOfOrten", new GuiClient(setCountOfOrten, null)); +} + +function setCountOfOrten(countOfOrten) { + console.log("setting value of 'count of Orten' to " + countOfOrten); + $("#labelCountOfOrten").text(countOfOrten); +} +//#endregion +//#endregion + +//#region form actions +//#region new +function InitButtonNew() { + EnableButtonNew(); + $("#buttonNew").click(openFormNewElement); +} + +function EnableButtonNew() { + $("#buttonNew").removeClass("disabled"); + $("#buttonNew").prop("disabled", false); +} + +function DisableButtonNew() { + $("#buttonNew").addClass("disabled"); + $("#buttonNew").prop("disabled", true); +} +//#endregion + +//#region save +function InitButtonSave() { + EnableButtonSave(); + $("#buttonSave").click(function () { _viewModelFormOrtType.save(); }); +} + +function EnableButtonSave() { + $("#buttonSave").removeClass("disabled"); + $("#buttonSave").prop("disabled", false); +} + +function DisableButtonSave() { + $("#buttonSave").addClass("disabled"); + $("#buttonSave").prop("disabled", true); +} +//#endregion + +//#region delete +function InitButtonDelete() { + DisableButtonDelete(); + $("#buttonDelete").click(ShowDialogDelete); +} + +function EnableButtonDelete() { + $("#buttonDelete").removeClass("disabled"); + $("#buttonDelete").prop("disabled", false); +} + +function DisableButtonDelete() { + $("#buttonDelete").addClass("disabled"); + $("#buttonDelete").prop("disabled", true); +} + +function ShowDialogDelete() { + $("#dialogDelete").empty(); + $("#dialogDelete").append( + $("

").append("Möchten Sie diesen Ortstyp löschen?") + ); + $("#dialogDelete").dialog({ + height: "auto", + width: 750, + modal: true, + buttons: { + "Löschen": function () { + _viewModelFormOrtType.delete(); + + $(this).dialog("close"); + }, + "Abbrechen": function () { + $(this).dialog("close"); + } + } + }); + + $("#DialogDelete").dialog("open"); +} +//#endregion + +//#region undo +function InitButtonUndo() { + DisableButtonUndo(); + _viewModelFormOrtType.register("dataResetted", new GuiClient(DisableButtonUndo, showErrorMessages)); + _viewModelFormOrtType.register("dataResetted", new GuiClient(ResetPropertiesMessages, showErrorMessages)); + $("#buttonUndo").click(function () { + console.log("button 'undo' clicked"); + _viewModelFormOrtType.undoAllChanges(); + }); +} + +function EnableButtonUndo() { + $("#buttonUndo").removeClass("disabled"); + $("#buttonUndo").prop("disabled", false); +} + +function DisableButtonUndo() { + $("#buttonUndo").addClass("disabled"); + $("#buttonUndo").prop("disabled", true); +} + +function ResetPropertiesMessages() { + $(".fieldValue div[name=messages]").empty(); +} +//#endregion + +//#region open list +function InitButtonToList() { + EnableButtonToList(); + $("#buttonToList").click( function() { + console.log("button 'to list' clicked"); + window.open("/Munins Archiv/src/OrtType/List.html", "_self"); + }); +} + +function EnableButtonToList() { + $("#buttonToList").removeClass("disabled"); + $("#buttonToList").prop("disabled", false); +} + +function DisableButtonToList() { + $("#buttonToList").addClass("disabled"); + $("#buttonToList").prop("disabled", true); +} +//#endregion +//#endregion \ No newline at end of file diff --git a/src/js/views/OrtType/List.js b/src/js/views/OrtType/List.js new file mode 100644 index 0000000..e5abec5 --- /dev/null +++ b/src/js/views/OrtType/List.js @@ -0,0 +1,253 @@ +var _viewModelListOrtType = null; + +$(document).ready(function () { + var viewModelFactory = new ViewModelFactory(); + _viewModelListOrtType = viewModelFactory.getViewModelListOrtType(); + + RegisterToViewModel(); + InitBreadcrumb(); + InitButtonNew(); + InitButtonEdit(); + InitButtonDelete(); + InitButtonReload(); + + InitGrid(); + + _viewModelListOrtType.loadAll(); +}); + +function InitBreadcrumb() +{ + $("#breadcrumb").Breadcrumb({ + PageName : "OrtTypeList" + }); +} + +function RegisterToViewModel() { + _viewModelListOrtType.register("dataChanged", new GuiClient(UpdateGridData, UpdateGridData)); + _viewModelListOrtType.register("loadAll", new GuiClient(showMessageAllLoaded, showErrorMessages)); + _viewModelListOrtType.register("create", new GuiClient(showMessageCreated, showErrorMessages)); + _viewModelListOrtType.register("delete", new GuiClient(showMessageDeleted, showErrorMessages)); + _viewModelListOrtType.register("itemSelected", new GuiClient(markSelectedItem, showErrorMessages)); + _viewModelListOrtType.register("itemSelected", new GuiClient(EnableButtonEdit, null)); + _viewModelListOrtType.register("itemSelected", new GuiClient(EnableButtonDelete, null)); + _viewModelListOrtType.register("selectionCleared", new GuiClient(clearSelectedItemHighlighting, null)); + _viewModelListOrtType.register("selectionCleared", new GuiClient(DisableButtonEdit, null)); + _viewModelListOrtType.register("selectionCleared", new GuiClient(DisableButtonDelete, null)); +} + +function clearSelectedItemHighlighting() { + $(".jsgrid-row, .jsgrid-alt-row").each(function(index){ + console.log("DEBUG: Removing css class from:") + console.log($(this)); + $(this).removeClass("selectedRow"); + }); +} + +function markSelectedItem(selectedItemArgs) { + clearSelectedItemHighlighting(); + + if (selectedItemArgs == undefined || + selectedItemArgs == null || + selectedItemArgs.Index == undefined) + { + console.log("ERROR: Setting selected item index is not set!") + return; + } + + console.log("DEBUG: Setting selected item:") + console.log(selectedItemArgs); + + var row = $(".jsgrid-row, .jsgrid-alt-row").eq(selectedItemArgs.Index) + + console.log("DEBUG: Selected row:"); + console.log(row); + + row.addClass("selectedRow"); +} + +function InitGrid() +{ + jsGrid.locale("de"); + ShowOrtTypes(); + UpdateGridData(new Array()); +} + +function UpdateGridData(ortTypes) { + $("#gridContainer").jsGrid({ + data: JSON.parse(JSON.stringify(ortTypes)) + }); +} + +function ShowOrtTypes() +{ + $("#gridContainer").jsGrid({ + width: "100%", + + inserting: false, + editing: false, + sorting: true, + paging: false, + autoload: false, + + fields: [ + { + name: "Bezeichnung", + type: "text", + validate: "required" + }, + { + title: "Anzahl von Orten", + name: "CountOfOrten", + type: "number", + inserting: false, + editing: false + } + ], + + rowClick: function(args) { + console.log("DEBUG: Selected element:"); + console.log(args.item); + _viewModelListOrtType.selectItem(args.item); + } + }); +} + +function setIdToEditLink(id) { + $("#buttonEdit").attr("href", "/Munins Archiv/src/OrtType/Form.html?Id=" + id); +} + +function showMessageAllLoaded(elements) { + $.toast({ + heading: "Information", + text: elements.length + " Ortstypen geladen", + icon: "info" + }); +} + +function showMessageCreated(element) { + $.toast({ + heading: "Information", + text: "Ortstyp \"" + element.Bezeichnung + "\" erzeugt", + icon: "success" + }); +} + +function showMessageSaved(element) { + $.toast({ + heading: "Information", + text: "Ortstyp \"" + element.Bezeichnung + "\" gespeichert", + icon: "success" + }); +} + +function showMessageDeleted(element) { + $.toast({ + heading: "Information", + text: "Ortstyp \"" + element.Bezeichnung + "\" gelöscht", + icon: "success" + }); +} + +//#region form actions +//#region new +function InitButtonNew() { + EnableButtonNew(); + $("#buttonNew").click(function () { + console.log("button 'new' clicked"); + window.open("/Munins Archiv/src/OrtType/Form.html", "_self"); + }); +} + +function EnableButtonNew() { + $("#buttonNew").removeClass("disabled"); + $("#buttonNew").prop("disabled", false); +} + +function DisableButtonNew() { + $("#buttonNew").addClass("disabled"); + $("#buttonNew").prop("disabled", true); +} +//#endregion + +//#region edit +function InitButtonEdit() { + DisableButtonEdit(); + $("#buttonEdit").click(function () { + console.log("button 'edit' clicked"); + window.open("/Munins Archiv/src/OrtType/Form.html?Id=" + _viewModelListOrtType.getSelectedItem().Id, "_self"); + }); +} + +function EnableButtonEdit() { + $("#buttonEdit").removeClass("disabled"); + $("#buttonEdit").prop("disabled", false); +} + +function DisableButtonEdit() { + $("#buttonEdit").addClass("disabled"); + $("#buttonEdit").prop("disabled", true); +} +//#endregion + +//#region delete +function InitButtonDelete() { + DisableButtonDelete(); + $("#buttonDelete").click(ShowDialogDelete); +} + +function EnableButtonDelete() { + $("#buttonDelete").removeClass("disabled"); + $("#buttonDelete").prop("disabled", false); +} + +function DisableButtonDelete() { + $("#buttonDelete").addClass("disabled"); + $("#buttonDelete").prop("disabled", true); +} + +function ShowDialogDelete() { + $("#dialogDelete").empty(); + $("#dialogDelete").append( + $("

").append("Möchten Sie den Orttyp \"" + _viewModelListOrtType.getSelectedItem().Bezeichnung + "\" löschen?") + ); + $("#dialogDelete").dialog({ + height: "auto", + width: 750, + modal: true, + buttons: { + "Löschen": function () { + _viewModelListOrtType.delete(_viewModelListOrtType.getSelectedItem()); + + $(this).dialog("close"); + }, + "Abbrechen": function () { + $(this).dialog("close"); + } + } + }); + + $("#DialogDelete").dialog("open"); +} +//#endregion + +//#region reload +function InitButtonReload() { + EnableButtonReload(); + $("#buttonReload").click(function () { + console.log("button 'reload' clicked"); + _viewModelListOrtType.loadAll(); + }); +} + +function EnableButtonReload() { + $("#buttonReload").removeClass("disabled"); + $("#buttonReload").prop("disabled", false); +} + +function DisableButtonReload() { + $("#buttonReload").addClass("disabled"); + $("#buttonReload").prop("disabled", true); +} +//#endregion +//#endregion \ No newline at end of file