WIP for the edit part of notification types.
authorSteve Sutton <steve@gaslightmedia.com>
Fri, 1 Dec 2017 21:43:56 +0000 (16:43 -0500)
committerSteve Sutton <steve@gaslightmedia.com>
Fri, 1 Dec 2017 21:43:56 +0000 (16:43 -0500)
Moving them into their own view files.

classes/data/dataNotificationTypes.php
models/admin/settings/notificationTypes.php
views/admin/settings/editNotificationType.html [new file with mode: 0644]
views/admin/settings/notificationTypes.html

index 42a76bc..c4f608b 100644 (file)
@@ -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',
             ),
 
             //
index d1a755f..215d2d8 100644 (file)
@@ -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 '<pre>$notificationTypes: ' . print_r( $notificationTypes, true ) . '</pre>';
+        echo '<pre>$notificationTypes: ' . print_r( $notificationTypes, true ) . '</pre>';
 
         // 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 (file)
index 0000000..722ac6a
--- /dev/null
@@ -0,0 +1,115 @@
+{include file='admin/settings/header.html'}
+
+{include file='admin/settings/subHeader.html'}
+
+Show error header here
+
+<form action="{$thisUrl}?page={$thisPage}&glm_action=notificationTypes">
+    {if $haveNotificationTypes}
+        <input type="hidden" name="option" value="update">
+    {else}
+        <input type="hidden" name="option" value="insert">
+    {/if}
+
+    <table class="glm-admin-table glm-event-table">
+
+        <tr>
+            <th {if $notificationTypes.fieldRequired.name} class="glm-required"}{/if}>Name</th>
+            <td {if $notificationTypes.fieldFail.name}class="glm-form-bad-input" data-tabid="glm-name"{/if}>
+                <input type="text" name="name" value="{$notificationTypes.fieldData.name}" class="glm-form-text-input-medium">
+            {if $notificationTypes.fieldFail.name}<p>{$notificationTypes.fieldFail.name}</p>{/if}<br>
+            </td>
+        </tr>
+
+        <tr>
+            <th colspan="2" class="glm-required">Send Notification based on</th>
+        </tr>
+        <tr>
+            <th colspan="2">Due Date</th>
+        </tr>
+        <tr>
+            <th class="glm-required"><input type="radio" name="send_by" value="date" required></th>
+            <td>
+                <input
+                    type="number"
+                    step="1"
+                    min="0"
+                    max="100"
+                    name="send_date_number"
+                    class="glm-form-text-input-veryshort">
+                <select name="send_date_period">
+                    {foreach $send_date_period as $id => $val}
+                        <option value="{$id}">{$val}</option>
+                    {/foreach}
+                </select>
+                <select name="send_date_when">
+                    {foreach $send_date_when as $id => $val}
+                        <option value="{$id}">{$val}</option>
+                    {/foreach}
+                </select>
+            </td>
+        </tr>
+        <tr>
+            <th colspan="2">Immediate Action</th>
+        </tr>
+        <tr>
+            <th><input type="radio" name="send_by" value="action" required></th>
+            <td>
+                <select name="send_action">
+                    {foreach $send_action as $id => $val}
+                        <option value="{$id}">{$val}</option>
+                    {/foreach}
+                </select>
+            </td>
+        </tr>
+
+        <tr>
+            <th {if $notificationTypes.fieldRequired.subject} class="glm-required"}{/if}>Subject</th>
+            <td {if $notificationTypes.fieldFail.subject}class="glm-form-bad-input" data-tabid="glm-subject"{/if}>
+                <input type="text" name="subject" value="{$notificationTypes.fieldData.subject}" class="glm-form-text-input-medium">
+            {if $notificationTypes.fieldFail.subject}<p>{$notificationTypes.fieldFail.subject}</p>{/if}<br>
+            </td>
+        </tr>
+
+        <tr>
+            <th {if $notificationTypes.fieldRequired.from_header} class="glm-required"}{/if}>From</th>
+            <td {if $notificationTypes.fieldFail.from_header}class="glm-form-bad-input" data-tabid="glm-fromheader"{/if}>
+                <input type="text" name="from_header" value="{$notificationTypes.fieldData.from_header}" class="glm-form-text-input-medium">
+            {if $notificationTypes.fieldFail.from_header}<p>{$notificationTypes.fieldFail.from_header}</p>{/if}<br>
+            </td>
+        </tr>
+
+        <tr>
+            <th {if $notificationTypes.fieldRequired.replyto} class="glm-required"}{/if}>Reply-To</th>
+            <td {if $notificationTypes.fieldFail.replyto}class="glm-form-bad-input" data-tabid="glm-replyto"{/if}>
+                <input type="text" name="replyto" value="{$notificationTypes.fieldData.replyto}" class="glm-form-text-input-medium">
+            {if $notificationTypes.fieldFail.replyto}<p>{$notificationTypes.fieldFail.replyto}</p>{/if}<br>
+            </td>
+        </tr>
+
+        <tr>
+            <th {if $notificationTypes.fieldRequired.message}class="glm-required"{/if}>Message:</th>
+            <td {if $notificationTypes.fieldFail.message}class="glm-form-bad-input" data-tabid="glm-message"{/if}>
+                {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}<p>{$notificationTypes.fieldFail.message}</p>{/if}
+            </td>
+        </tr>
+
+        <tr>
+            <td colspan="2">
+                <input class="button button-primary" type="submit" value="{if $haveNotificationTypes}Update{else}Add{/if} Notification Type">
+            </td>
+        </tr>
+
+
+    </table>
+</form>
+
+
+{include file='admin/footer.html'}
index 8d65dbc..bf2d746 100644 (file)
@@ -3,7 +3,7 @@
 {include file='admin/settings/subHeader.html'}
 
 <!-- Add NotificationTypes Button and Dialog Box -->
-<div id="newNotificationTypeButton" class="button button-primary glm-right">Add a Notification Type</div>
+<a href="{$thisUrl}?page={$thisPage}&glm_action=notificationTypes&option=add" class="button button-primary glm-right">Add a Notification Type</a>
 <div id="newNotificationTypeDialog" class="glm-dialog-box" title="Enter a New NotificationType">
     <form action="{$thisUrl}?page={$thisPage}&glm_action=notificationTypes" method="post" enctype="multipart/form-data">
         <input type="hidden" name="glm_action" value="notificationTypes">
             dialogClass: "glm-dialog-no-close"
         });
 
-        $('#newNotificationTypeButton').click( function() {
-            $("#newNotificationTypeDialog").dialog("open");
-        });
+        // $('#newNotificationTypeButton').click( function() {
+        //     $("#newNotificationTypeDialog").dialog("open");
+        // });
         $('.editNotificationType').click( function() {
             $('#editRecurring').prop( 'checked', false );