From 2abfa17fc31fa0b4ccb7641cc81ef9a09044c305 Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Mon, 14 Jun 2021 18:45:40 -0700 Subject: [PATCH] msgtplui - Add skeletal listing of msg tpls --- .../CRM/Msgtplui/Page/MsgtplBasePage.php | 17 ++++++ ext/msgtplui/ang/msgtplui.ang.php | 33 ++++++++++++ ext/msgtplui/ang/msgtplui.css | 1 + ext/msgtplui/ang/msgtplui.js | 4 ++ ext/msgtplui/ang/msgtplui/Edit.html | 52 +++++++++++++++++++ ext/msgtplui/ang/msgtplui/Edit.js | 51 ++++++++++++++++++ ext/msgtplui/ang/msgtplui/User.html | 21 ++++++++ ext/msgtplui/ang/msgtplui/User.js | 32 ++++++++++++ ext/msgtplui/ang/msgtplui/Workflow.html | 31 +++++++++++ ext/msgtplui/ang/msgtplui/Workflow.js | 35 +++++++++++++ ext/msgtplui/templates/CRM/msgtplui/Edit.hlp | 3 ++ .../CRM/msgtplui/Page/MsgtplBasePage.tpl | 2 + ext/msgtplui/templates/CRM/msgtplui/User.hlp | 3 ++ .../templates/CRM/msgtplui/Workflow.hlp | 3 ++ ext/msgtplui/xml/Menu/msgtplui.xml | 9 ++++ 15 files changed, 297 insertions(+) create mode 100644 ext/msgtplui/CRM/Msgtplui/Page/MsgtplBasePage.php create mode 100644 ext/msgtplui/ang/msgtplui.ang.php create mode 100644 ext/msgtplui/ang/msgtplui.css create mode 100644 ext/msgtplui/ang/msgtplui.js create mode 100644 ext/msgtplui/ang/msgtplui/Edit.html create mode 100644 ext/msgtplui/ang/msgtplui/Edit.js create mode 100644 ext/msgtplui/ang/msgtplui/User.html create mode 100644 ext/msgtplui/ang/msgtplui/User.js create mode 100644 ext/msgtplui/ang/msgtplui/Workflow.html create mode 100644 ext/msgtplui/ang/msgtplui/Workflow.js create mode 100644 ext/msgtplui/templates/CRM/msgtplui/Edit.hlp create mode 100644 ext/msgtplui/templates/CRM/msgtplui/Page/MsgtplBasePage.tpl create mode 100644 ext/msgtplui/templates/CRM/msgtplui/User.hlp create mode 100644 ext/msgtplui/templates/CRM/msgtplui/Workflow.hlp create mode 100644 ext/msgtplui/xml/Menu/msgtplui.xml diff --git a/ext/msgtplui/CRM/Msgtplui/Page/MsgtplBasePage.php b/ext/msgtplui/CRM/Msgtplui/Page/MsgtplBasePage.php new file mode 100644 index 0000000000..baa00d4e1f --- /dev/null +++ b/ext/msgtplui/CRM/Msgtplui/Page/MsgtplBasePage.php @@ -0,0 +1,17 @@ +setModules(['msgtplui']); + $loader->useApp(array( + 'defaultRoute' => '/user', + )); + parent::run(); + } + +} diff --git a/ext/msgtplui/ang/msgtplui.ang.php b/ext/msgtplui/ang/msgtplui.ang.php new file mode 100644 index 0000000000..ddf0e71b0a --- /dev/null +++ b/ext/msgtplui/ang/msgtplui.ang.php @@ -0,0 +1,33 @@ + [ + 'ang/msgtplui.js', + 'ang/msgtplui/*.js', + 'ang/msgtplui/*/*.js', + ], + 'css' => [ + 'ang/msgtplui.css', + ], + 'partials' => [ + 'ang/msgtplui', + ], + 'bundles' => [ + 'bootstrap3', + ], + 'requires' => [ + 'crmUi', + 'crmUtil', + 'ngRoute', + 'api4', + ], + 'settings' => [], + 'basePages' => [], + 'permissions' => [ + "edit message templates", + "edit user-driven message templates", + "edit system workflow message templates", + ], +]; diff --git a/ext/msgtplui/ang/msgtplui.css b/ext/msgtplui/ang/msgtplui.css new file mode 100644 index 0000000000..98e45b233b --- /dev/null +++ b/ext/msgtplui/ang/msgtplui.css @@ -0,0 +1 @@ +/* Add any CSS rules for Angular module "msgtplui" */ diff --git a/ext/msgtplui/ang/msgtplui.js b/ext/msgtplui/ang/msgtplui.js new file mode 100644 index 0000000000..47b27fac85 --- /dev/null +++ b/ext/msgtplui/ang/msgtplui.js @@ -0,0 +1,4 @@ +(function(angular, $, _) { + // Declare a list of dependencies. + angular.module('msgtplui', CRM.angRequires('msgtplui')); +})(angular, CRM.$, CRM._); diff --git a/ext/msgtplui/ang/msgtplui/Edit.html b/ext/msgtplui/ang/msgtplui/Edit.html new file mode 100644 index 0000000000..db4703271e --- /dev/null +++ b/ext/msgtplui/ang/msgtplui/Edit.html @@ -0,0 +1,52 @@ +
+ + The edit view. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/ext/msgtplui/ang/msgtplui/Edit.js b/ext/msgtplui/ang/msgtplui/Edit.js new file mode 100644 index 0000000000..6783a97473 --- /dev/null +++ b/ext/msgtplui/ang/msgtplui/Edit.js @@ -0,0 +1,51 @@ +(function(angular, $, _) { + + angular.module('msgtplui').config(function($routeProvider) { + $routeProvider.when('/edit', { + controller: 'MsgtpluiEdit', + controllerAs: '$ctrl', + templateUrl: '~/msgtplui/Edit.html', + + // If you need to look up data when opening the page, list it out + // under "resolve". + resolve: { + myContact: function(crmApi) { + return crmApi('Contact', 'getsingle', { + id: 'user_contact_id', + return: ['first_name', 'last_name'] + }); + } + } + }); + } + ); + + // The controller uses *injection*. This default injects a few things: + // $scope -- This is the set of variables shared between JS and HTML. + // crmApi, crmStatus, crmUiHelp -- These are services provided by civicrm-core. + // myContact -- The current contact, defined above in config(). + angular.module('msgtplui').controller('MsgtpluiEdit', function($scope, crmApi, crmStatus, crmUiHelp, myContact) { + // The ts() and hs() functions help load strings for this module. + var ts = $scope.ts = CRM.ts('msgtplui'); + var hs = $scope.hs = crmUiHelp({file: 'CRM/msgtplui/Edit'}); // See: templates/CRM/msgtplui/Edit.hlp + // Local variable for this controller (needed when inside a callback fn where `this` is not available). + var ctrl = this; + + // We have myContact available in JS. We also want to reference it in HTML. + this.myContact = myContact; + + this.save = function() { + return crmStatus( + // Status messages. For defaults, just use "{}" + {start: ts('Saving...'), success: ts('Saved')}, + // The save action. Note that crmApi() returns a promise. + crmApi('Contact', 'create', { + id: ctrl.myContact.id, + first_name: ctrl.myContact.first_name, + last_name: ctrl.myContact.last_name + }) + ); + }; + }); + +})(angular, CRM.$, CRM._); diff --git a/ext/msgtplui/ang/msgtplui/User.html b/ext/msgtplui/ang/msgtplui/User.html new file mode 100644 index 0000000000..4aa075218a --- /dev/null +++ b/ext/msgtplui/ang/msgtplui/User.html @@ -0,0 +1,21 @@ +
+
+ + + + + + + + + + + + + + +
{{ts('Title')}}
{{msgtpl.msg_title}} + (...Actions...) +
+ +
diff --git a/ext/msgtplui/ang/msgtplui/User.js b/ext/msgtplui/ang/msgtplui/User.js new file mode 100644 index 0000000000..6238b1b2d6 --- /dev/null +++ b/ext/msgtplui/ang/msgtplui/User.js @@ -0,0 +1,32 @@ +(function(angular, $, _) { + + angular.module('msgtplui').config(function($routeProvider) { + $routeProvider.when('/user', { + controller: 'MsgtpluiUser', + controllerAs: '$ctrl', + templateUrl: '~/msgtplui/User.html', + resolve: { + records: function(crmApi4) { + return crmApi4('MessageTemplate', 'get', { + select: ["id", "msg_title", "is_default"], + where: [["workflow_name", "IS EMPTY"]], + orderBy: {"msg_title":"ASC"}, + }); + } + } + }); + } + ); + + // The controller uses *injection*. This default injects a few things: + // $scope -- This is the set of variables shared between JS and HTML. + // crmApi, crmStatus, crmUiHelp -- These are services provided by civicrm-core. + // myContact -- The current contact, defined above in config(). + angular.module('msgtplui').controller('MsgtpluiUser', function($scope, crmApi, crmStatus, crmUiHelp, records) { + var ts = $scope.ts = CRM.ts('msgtplui'); + var hs = $scope.hs = crmUiHelp({file: 'CRM/msgtplui/User'}); // See: templates/CRM/msgtplui/User.hlp + var ctrl = this; + ctrl.records = records; + }); + +})(angular, CRM.$, CRM._); diff --git a/ext/msgtplui/ang/msgtplui/Workflow.html b/ext/msgtplui/ang/msgtplui/Workflow.html new file mode 100644 index 0000000000..f1e625273a --- /dev/null +++ b/ext/msgtplui/ang/msgtplui/Workflow.html @@ -0,0 +1,31 @@ +
+
+ + + + + + + + + + + + + + + + + + + + +
{{ts('Title')}}{{ts('Locale')}}{{ts('Current')}}{{ts('Draft')}}{{ts('Translate')}}
{{msgtpl.msg_title}}{{msgtpl['tx.language:label']}} + Current + + Draft + + Translate +
+ +
diff --git a/ext/msgtplui/ang/msgtplui/Workflow.js b/ext/msgtplui/ang/msgtplui/Workflow.js new file mode 100644 index 0000000000..7198f34fb0 --- /dev/null +++ b/ext/msgtplui/ang/msgtplui/Workflow.js @@ -0,0 +1,35 @@ +(function(angular, $, _) { + + angular.module('msgtplui').config(function($routeProvider) { + $routeProvider.when('/workflow', { + controller: 'MsgtpluiWorkflow', + controllerAs: '$ctrl', + templateUrl: '~/msgtplui/Workflow.html', + resolve: { + records: function(crmApi4) { + return crmApi4('MessageTemplate', 'get', { + select: ["id", "msg_title", "tx.language:label", "tx.language", "is_default"], + join: [["Translation AS tx", "LEFT", null, ["tx.entity_table", "=", "'civicrm_msg_template'"], ["tx.entity_id", "=", "id"]]], + where: [["workflow_name", "IS NOT EMPTY"]], + groupBy: ["id", "tx.language"], + orderBy: {"msg_title":"ASC"}, + chain: {"statuses":["Translation", "get", {"select":["status_id:name"], "where":[["entity_table", "=", "civicrm_msg_template"], ["entity_id", "=", "$id"], ["language", "=", "$tx.language"]], "groupBy":["status_id"]}, "status_id:name"]} + }); + }, + }, + }); + } + ); + + // The controller uses *injection*. This default injects a few things: + // $scope -- This is the set of variables shared between JS and HTML. + // crmApi, crmStatus, crmUiHelp -- These are services provided by civicrm-core. + // myContact -- The current contact, defined above in config(). + angular.module('msgtplui').controller('MsgtpluiWorkflow', function($scope, crmStatus, crmUiHelp, records) { + var ts = $scope.ts = CRM.ts('msgtplui'); + var hs = $scope.hs = crmUiHelp({file: 'CRM/msgtplui/Workflow'}); // See: templates/CRM/msgtplui/Workflow.hlp + var ctrl = this; + ctrl.records = records; + }); + +})(angular, CRM.$, CRM._); diff --git a/ext/msgtplui/templates/CRM/msgtplui/Edit.hlp b/ext/msgtplui/templates/CRM/msgtplui/Edit.hlp new file mode 100644 index 0000000000..ddea10c3e3 --- /dev/null +++ b/ext/msgtplui/templates/CRM/msgtplui/Edit.hlp @@ -0,0 +1,3 @@ +{htxt id="full_name"} +{ts}The contact name should be divided in two parts, the first name and last name.{/ts} +{/htxt} diff --git a/ext/msgtplui/templates/CRM/msgtplui/Page/MsgtplBasePage.tpl b/ext/msgtplui/templates/CRM/msgtplui/Page/MsgtplBasePage.tpl new file mode 100644 index 0000000000..0a3b96aa8c --- /dev/null +++ b/ext/msgtplui/templates/CRM/msgtplui/Page/MsgtplBasePage.tpl @@ -0,0 +1,2 @@ +{* Placeholder *} + diff --git a/ext/msgtplui/templates/CRM/msgtplui/User.hlp b/ext/msgtplui/templates/CRM/msgtplui/User.hlp new file mode 100644 index 0000000000..ddea10c3e3 --- /dev/null +++ b/ext/msgtplui/templates/CRM/msgtplui/User.hlp @@ -0,0 +1,3 @@ +{htxt id="full_name"} +{ts}The contact name should be divided in two parts, the first name and last name.{/ts} +{/htxt} diff --git a/ext/msgtplui/templates/CRM/msgtplui/Workflow.hlp b/ext/msgtplui/templates/CRM/msgtplui/Workflow.hlp new file mode 100644 index 0000000000..ddea10c3e3 --- /dev/null +++ b/ext/msgtplui/templates/CRM/msgtplui/Workflow.hlp @@ -0,0 +1,3 @@ +{htxt id="full_name"} +{ts}The contact name should be divided in two parts, the first name and last name.{/ts} +{/htxt} diff --git a/ext/msgtplui/xml/Menu/msgtplui.xml b/ext/msgtplui/xml/Menu/msgtplui.xml new file mode 100644 index 0000000000..43097226c7 --- /dev/null +++ b/ext/msgtplui/xml/Menu/msgtplui.xml @@ -0,0 +1,9 @@ + + + + civicrm/admin/messageTemplates + CRM_Msgtplui_Page_MsgtplBasePage + MsgtplBasePage + access CiviCRM + + -- 2.25.1