From ee6be2e22ccecee5fa73c17fd927715f77161ad3 Mon Sep 17 00:00:00 2001 From: Naomi Date: Tue, 1 Apr 2014 15:37:19 -0400 Subject: [PATCH] CC-5765 : Fixing up history page to match UI/UX fixing dialog buttons to match most other dialogs in Airtime. Puttin context menu on right click, short cut to edit by double clicking. --- .../controllers/PlayouthistoryController.php | 2 + airtime_mvc/application/forms/EditHistory.php | 20 --- .../scripts/form/edit-history-file.phtml | 6 - .../scripts/form/edit-history-item.phtml | 8 +- .../js/airtime/playouthistory/historytable.js | 164 +++++++++--------- 5 files changed, 83 insertions(+), 117 deletions(-) diff --git a/airtime_mvc/application/controllers/PlayouthistoryController.php b/airtime_mvc/application/controllers/PlayouthistoryController.php index 79d60ac71..18de7d871 100644 --- a/airtime_mvc/application/controllers/PlayouthistoryController.php +++ b/airtime_mvc/application/controllers/PlayouthistoryController.php @@ -187,6 +187,7 @@ class PlayouthistoryController extends Zend_Controller_Action $this->view->form = $form; $this->view->dialog = $this->view->render('playouthistory/dialog.phtml'); + $this->view->prefix = $form::ID_PREFIX; unset($this->view->form); } @@ -227,6 +228,7 @@ class PlayouthistoryController extends Zend_Controller_Action $this->view->form = $form; $this->view->dialog = $this->view->render('playouthistory/dialog.phtml'); + $this->view->prefix = $form::ID_PREFIX; unset($this->view->form); } diff --git a/airtime_mvc/application/forms/EditHistory.php b/airtime_mvc/application/forms/EditHistory.php index 9fdc75643..7171383ce 100644 --- a/airtime_mvc/application/forms/EditHistory.php +++ b/airtime_mvc/application/forms/EditHistory.php @@ -120,26 +120,6 @@ class Application_Form_EditHistory extends Zend_Form $dynamic_attrs = new Zend_Form_SubForm(); $this->addSubForm($dynamic_attrs, $this::ID_PREFIX.'template'); - - // Add the submit button - $this->addElement('button', $this::ID_PREFIX.'save', array( - 'ignore' => true, - 'class' => 'btn '.$this::ID_PREFIX.'save', - 'label' => _('Save'), - 'decorators' => array( - 'ViewHelper' - ) - )); - - // Add the cancel button - $this->addElement('button', $this::ID_PREFIX.'cancel', array( - 'ignore' => true, - 'class' => 'btn '.$this::ID_PREFIX.'cancel', - 'label' => _('Cancel'), - 'decorators' => array( - 'ViewHelper' - ) - )); } protected function getTemplateSubForm() { diff --git a/airtime_mvc/application/views/scripts/form/edit-history-file.phtml b/airtime_mvc/application/views/scripts/form/edit-history-file.phtml index 83272200c..d83ab027a 100644 --- a/airtime_mvc/application/views/scripts/form/edit-history-file.phtml +++ b/airtime_mvc/application/views/scripts/form/edit-history-file.phtml @@ -26,12 +26,6 @@ -
- -getElement($name); ?> - -
- \ No newline at end of file diff --git a/airtime_mvc/application/views/scripts/form/edit-history-item.phtml b/airtime_mvc/application/views/scripts/form/edit-history-item.phtml index 519eac285..133442908 100644 --- a/airtime_mvc/application/views/scripts/form/edit-history-item.phtml +++ b/airtime_mvc/application/views/scripts/form/edit-history-item.phtml @@ -46,7 +46,7 @@ - + @@ -68,12 +68,6 @@ -
- -getElement($name); ?> - -
- diff --git a/airtime_mvc/public/js/airtime/playouthistory/historytable.js b/airtime_mvc/public/js/airtime/playouthistory/historytable.js index 2ba7e8f17..5c431ddeb 100644 --- a/airtime_mvc/public/js/airtime/playouthistory/historytable.js +++ b/airtime_mvc/public/js/airtime/playouthistory/historytable.js @@ -534,21 +534,91 @@ var AIRTIME = (function(AIRTIME) { return $el; } - function makeHistoryDialog(html) { - $hisDialogEl = $(html); + function fileSave() { + var data = $hisDialogEl.serializeArray(); + var url = baseUrl+"Playouthistory/update-file-item/format/json"; + + $.post(url, data, function(json) { + + //TODO put errors on form. + if (json.error !== undefined) { + //makeHistoryDialog(json.dialog); + } + else { + removeHistoryDialog(); + redrawTables(); + } + + }, "json"); + + } + + function itemSave() { + + var data = $hisDialogEl.serializeArray(), + id = data[0].value, + createUrl = baseUrl+"Playouthistory/create-list-item/format/json", + updateUrl = baseUrl+"Playouthistory/update-list-item/format/json", + url, + $select = $hisDialogEl.find("#his_instance_select"), + instance; + + url = (id === "") ? createUrl : updateUrl; + + if (fnServerData.instance !== undefined) { + data.push({ + name: "instance_id", + value: fnServerData.instance + }); + } + else if ($select.length > 0) { + instance = $select.val(); + + if (instance > 0) { + data.push({ + name: "instance_id", + value: instance + }); + } + } + + $.post(url, data, function(json) { + + if (json.form !== undefined) { + var $newForm = $(json.form); + $newForm = processDialogHtml($newForm); + $hisDialogEl.html($newForm.html()); + initializeDialog(); + } + else { + removeHistoryDialog(); + redrawTables(); + } + + }, "json"); + + } + + function makeHistoryDialog(json) { + $hisDialogEl = $(json.dialog); $hisDialogEl = processDialogHtml($hisDialogEl); + var saveCallback = { + "his_item_": itemSave, + "his_file_": fileSave + }; + $hisDialogEl.dialog({ title: $.i18n._("Edit History Record"), modal: false, open: function( event, ui ) { initializeDialog(); }, - close: removeHistoryDialog - // buttons: [ - // {text: $.i18n._("Cancel"), class: "btn btn-small", click: removeDialog}, - // {text: $.i18n._("Save"), class: "btn btn-small btn-inverse", click: saveDialog} - //] + close: removeHistoryDialog, + buttons: [ + {text: $.i18n._("Cancel"), class: "btn btn-small", click: removeHistoryDialog}, + {text: $.i18n._("Save"), class: "btn btn-small btn-inverse", click: saveCallback[json.prefix]} + ] }); } @@ -607,7 +677,7 @@ var AIRTIME = (function(AIRTIME) { $.get(url, function(json) { - makeHistoryDialog(json.dialog); + makeHistoryDialog(json); }, "json"); }); @@ -616,80 +686,6 @@ var AIRTIME = (function(AIRTIME) { removeHistoryDialog(); }); - $('body').on("click", ".his_file_save", function(e) { - - e.preventDefault(); - - var $form = $(this).parents("form"); - var data = $form.serializeArray(); - - var url = baseUrl+"Playouthistory/update-file-item/format/json"; - - $.post(url, data, function(json) { - - //TODO put errors on form. - if (json.error !== undefined) { - //makeHistoryDialog(json.dialog); - } - else { - removeHistoryDialog(); - redrawTables(); - } - - }, "json"); - - }); - - $('body').on("click", ".his_item_save", function(e) { - - e.preventDefault(); - - var $form = $(this).parents("form"), - data = $form.serializeArray(), - id = data[0].value, - createUrl = baseUrl+"Playouthistory/create-list-item/format/json", - updateUrl = baseUrl+"Playouthistory/update-list-item/format/json", - url, - $select = $hisDialogEl.find("#his_instance_select"), - instance; - - url = (id === "") ? createUrl : updateUrl; - - if (fnServerData.instance !== undefined) { - data.push({ - name: "instance_id", - value: fnServerData.instance - }); - } - else if ($select.length > 0) { - instance = $select.val(); - - if (instance > 0) { - data.push({ - name: "instance_id", - value: instance - }); - } - } - - $.post(url, data, function(json) { - - if (json.form !== undefined) { - var $newForm = $(json.form); - $newForm = processDialogHtml($newForm); - $hisDialogEl.html($newForm.html()); - initializeDialog(); - } - else { - removeHistoryDialog(); - redrawTables(); - } - - }, "json"); - - }); - - $historyContentDiv.on("click", ".his_checkbox input", function(e) { var checked = e.currentTarget.checked, $tr = $(e.currentTarget).parents("tr"); @@ -809,7 +805,7 @@ var AIRTIME = (function(AIRTIME) { $.post(editUrl, {format: "json"}, function(json) { - makeHistoryDialog(json.dialog); + makeHistoryDialog(json); }, "json"); }); @@ -836,7 +832,7 @@ var AIRTIME = (function(AIRTIME) { callback = function() { $.post(editUrl, {format: "json"}, function(json) { - makeHistoryDialog(json.dialog); + makeHistoryDialog(json); }, "json"); };