From 9e04ed0e56dd8c8da11528d0bb3e0d6d57df64bb Mon Sep 17 00:00:00 2001 From: Steve Sutton Date: Fri, 1 Dec 2017 16:43:56 -0500 Subject: [PATCH] WIP for the edit part of notification types. Moving them into their own view files. --- classes/data/dataNotificationTypes.php | 43 ++++--- models/admin/settings/notificationTypes.php | 61 ++++++---- .../admin/settings/editNotificationType.html | 115 ++++++++++++++++++ views/admin/settings/notificationTypes.html | 8 +- 4 files changed, 180 insertions(+), 47 deletions(-) create mode 100644 views/admin/settings/editNotificationType.html diff --git a/classes/data/dataNotificationTypes.php b/classes/data/dataNotificationTypes.php index 42a76bc..c4f608b 100644 --- a/classes/data/dataNotificationTypes.php +++ b/classes/data/dataNotificationTypes.php @@ -124,37 +124,42 @@ class GlmDataNotificationTypes extends GlmDataAbstract // Notification Type Name 'name' => array( - 'field' => 'name', - 'type' => 'text', - 'use' => 'a', + 'field' => 'name', + 'type' => 'text', + 'required' => true, + 'use' => 'a', ), // - 'from_header' => array( - 'field' => 'from_header', - 'type' => 'text', - 'use' => 'a', + 'from_header' => array( + 'field' => 'from_header', + 'type' => 'text', + 'required' => true, + 'use' => 'a', ), // - 'replyto' => array( - 'field' => 'replyto', - 'type' => 'text', - 'use' => 'a', + 'replyto' => array( + 'field' => 'replyto', + 'type' => 'text', + 'required' => true, + 'use' => 'a', ), // - 'subject' => array( - 'field' => 'subject', - 'type' => 'text', - 'use' => 'a', + 'subject' => array( + 'field' => 'subject', + 'type' => 'text', + 'required' => true, + 'use' => 'a', ), // - 'message' => array( - 'field' => 'message', - 'type' => 'text', - 'use' => 'a', + 'message' => array( + 'field' => 'message', + 'type' => 'text', + 'required' => true, + 'use' => 'a', ), // diff --git a/models/admin/settings/notificationTypes.php b/models/admin/settings/notificationTypes.php index d1a755f..215d2d8 100644 --- a/models/admin/settings/notificationTypes.php +++ b/models/admin/settings/notificationTypes.php @@ -99,6 +99,8 @@ class GlmMembersAdmin_settings_notificationTypes extends GlmDataNotificationType public function modelAction ($actionData = false) { + $option = 'list'; + $view = 'notificationTypes'; $success = true; $haveNotificationTypes = false; $notificationTypes = false; @@ -129,37 +131,48 @@ class GlmMembersAdmin_settings_notificationTypes extends GlmDataNotificationType } } - // If there's an action option + // Get any provided option if (isset($_REQUEST['option'])) { + $option = $_REQUEST['option']; + } - switch($_REQUEST['option']) { - - case 'addNew': - - - $this->insertEntry(); - break; - - case 'update': - if ($id > 0) { - $this->updateEntry($id); - } - break; - - case 'delete': - if ($id > 0) { - $this->deleteEntry($id, true); - } - break; + switch($_REQUEST['option']) { + case 'add': + $this->newEntry(); + $view = 'editNotificationType'; + break; + + case 'insert': + $view = 'editNotificationType'; + $this->insertEntry(); + $notificationTypes = $this->getList(); + break; + + case 'edit': + $notificationTypes = $this->editEntry( $this->notification_id ); + break; + + case 'update': + if ($id > 0) { + $this->updateEntry($id); + } + $notificationTypes = $this->getList(); + break; + case 'delete': + if ($id > 0) { + $this->deleteEntry($id, true); } + case 'list': + default: + // Get a current list of members + $notificationTypes = $this->getList(); + break; } - // Get a current list of members - $notificationTypes = $this->getList(); - // echo '
$notificationTypes: ' . print_r( $notificationTypes, true ) . '
'; + echo '
$notificationTypes: ' . print_r( $notificationTypes, true ) . '
'; // If we have list entries - even if it's an empty list $success = true; @@ -201,7 +214,7 @@ class GlmMembersAdmin_settings_notificationTypes extends GlmDataNotificationType 'status' => $success, 'menuItemRedirect' => false, 'modelRedirect' => false, - 'view' => 'admin/settings/notificationTypes.html', + 'view' => 'admin/settings/' . $view . '.html', 'data' => $templateData ); diff --git a/views/admin/settings/editNotificationType.html b/views/admin/settings/editNotificationType.html new file mode 100644 index 0000000..722ac6a --- /dev/null +++ b/views/admin/settings/editNotificationType.html @@ -0,0 +1,115 @@ +{include file='admin/settings/header.html'} + +{include file='admin/settings/subHeader.html'} + +Show error header here + +
+ {if $haveNotificationTypes} + + {else} + + {/if} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Name + + {if $notificationTypes.fieldFail.name}

{$notificationTypes.fieldFail.name}

{/if}
+
Send Notification based on
Due Date
+ + + +
Immediate Action
+ +
Subject + + {if $notificationTypes.fieldFail.subject}

{$notificationTypes.fieldFail.subject}

{/if}
+
From + + {if $notificationTypes.fieldFail.from_header}

{$notificationTypes.fieldFail.from_header}

{/if}
+
Reply-To + + {if $notificationTypes.fieldFail.replyto}

{$notificationTypes.fieldFail.replyto}

{/if}
+
Message: + {php} + wp_editor('{$notificationTypes.fieldData.message|escape:quotes}', 'glm_descr', array( + 'media_buttons' => false, + 'textarea_name' => 'message', + 'editor_height' => 200, + )); + {/php} + {if $notificationTypes.fieldFail.message}

{$notificationTypes.fieldFail.message}

{/if} +
+ +
+
+ + +{include file='admin/footer.html'} diff --git a/views/admin/settings/notificationTypes.html b/views/admin/settings/notificationTypes.html index 8d65dbc..bf2d746 100644 --- a/views/admin/settings/notificationTypes.html +++ b/views/admin/settings/notificationTypes.html @@ -3,7 +3,7 @@ {include file='admin/settings/subHeader.html'} -
Add a Notification Type
+Add a Notification Type
@@ -264,9 +264,9 @@ dialogClass: "glm-dialog-no-close" }); - $('#newNotificationTypeButton').click( function() { - $("#newNotificationTypeDialog").dialog("open"); - }); + // $('#newNotificationTypeButton').click( function() { + // $("#newNotificationTypeDialog").dialog("open"); + // }); $('.editNotificationType').click( function() { $('#editRecurring').prop( 'checked', false ); -- 2.17.1