You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nifi.apache.org by mc...@apache.org on 2015/04/07 18:35:52 UTC

[2/2] incubator-nifi git commit: NIFI-475: - Prompting the user to save changes before navigating to the controller service definition.

NIFI-475:
- Prompting the user to save changes before navigating to the controller service definition.

Project: http://git-wip-us.apache.org/repos/asf/incubator-nifi/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-nifi/commit/eb591271
Tree: http://git-wip-us.apache.org/repos/asf/incubator-nifi/tree/eb591271
Diff: http://git-wip-us.apache.org/repos/asf/incubator-nifi/diff/eb591271

Branch: refs/heads/NIFI-475
Commit: eb5912711b65244cee538b14c84b49cefbd8d472
Parents: 780da7f
Author: Matt Gilman <ma...@gmail.com>
Authored: Tue Apr 7 12:35:41 2015 -0400
Committer: Matt Gilman <ma...@gmail.com>
Committed: Tue Apr 7 12:35:41 2015 -0400

----------------------------------------------------------------------
 .../webapp/js/nf/canvas/nf-reporting-task.js    | 131 +++++++++++--------
 1 file changed, 80 insertions(+), 51 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/eb591271/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-reporting-task.js
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-reporting-task.js b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-reporting-task.js
index 960251e..998213e 100644
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-reporting-task.js
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-reporting-task.js
@@ -207,6 +207,70 @@ nf.ReportingTask = (function () {
     };
     
     /**
+     * Goes to a service configuration from the property table.
+     */
+    var goToServiceFromProperty = function () {
+        return $.Deferred(function (deferred) {
+            // close all fields currently being edited
+            $('#reporting-task-properties').propertytable('saveRow');
+
+            // determine if changes have been made
+            if (isSaveRequired()) {
+                // see if those changes should be saved
+                nf.Dialog.showYesNoDialog({
+                    dialogContent: 'Save changes before going to this Controller Service?',
+                    overlayBackground: false,
+                    noHandler: function () {
+                        deferred.resolve();
+                    },
+                    yesHandler: function () {
+                        var reportingTask = $('#reporting-task-configuration').data('reportingTaskDetails');
+                        saveReportingTask(reportingTask).done(function () {
+                            deferred.resolve();
+                        }).fail(function () {
+                            deferred.reject();
+                        });
+                    }
+                });
+            } else {
+                deferred.resolve();
+            }
+        }).promise();
+    };
+    
+    /**
+     * Saves the specified reporting task.
+     * 
+     * @param {type} reportingTask
+     */
+    var saveReportingTask = function (reportingTask) {
+        // marshal the settings and properties and update the reporting task
+        var updatedReportingTask = marshalDetails();
+
+        // ensure details are valid as far as we can tell
+        if (validateDetails(updatedReportingTask)) {
+            // update the selected component
+            return $.ajax({
+                type: 'PUT',
+                data: JSON.stringify(updatedReportingTask),
+                url: reportingTask.uri,
+                dataType: 'json',
+                processData: false,
+                contentType: 'application/json'
+            }).done(function (response) {
+                if (nf.Common.isDefinedAndNotNull(response.reportingTask)) {
+                    // update the revision
+                    nf.Client.setRevision(response.revision);
+                }
+            }).fail(handleReportingTaskConfigurationError);
+        } else {
+            return $.Deferred(function (deferred) {
+                deferred.reject();
+            }).promise();
+        }
+    };
+    
+    /**
      * Gets a property descriptor for the controller service currently being configured.
      * 
      * @param {type} propertyName
@@ -289,7 +353,8 @@ nf.ReportingTask = (function () {
             $('#reporting-task-properties').propertytable({
                 readOnly: false,
                 dialogContainer: '#new-reporting-task-property-container',
-                deferredDescriptor: getReportingTaskPropertyDescriptor
+                deferredDescriptor: getReportingTaskPropertyDescriptor,
+                goToServiceDeferred: goToServiceFromProperty
             });
         },
         
@@ -309,7 +374,8 @@ nf.ReportingTask = (function () {
                 $('#reporting-task-properties').propertytable('destroy').propertytable({
                     readOnly: false,
                     dialogContainer: '#new-reporting-task-property-container',
-                    deferredDescriptor: getReportingTaskPropertyDescriptor
+                    deferredDescriptor: getReportingTaskPropertyDescriptor,
+                    goToServiceDeferred: goToServiceFromProperty
                 });
                 
                 // update the mode
@@ -407,33 +473,15 @@ nf.ReportingTask = (function () {
                                 // close all fields currently being edited
                                 $('#reporting-task-properties').propertytable('saveRow');
 
-                                // marshal the settings and properties and update the reporting task
-                                var updatedReportingTask = marshalDetails();
-
-                                // ensure details are valid as far as we can tell
-                                if (validateDetails(updatedReportingTask)) {
-                                    // update the selected component
-                                    $.ajax({
-                                        type: 'PUT',
-                                        data: JSON.stringify(updatedReportingTask),
-                                        url: reportingTask.uri,
-                                        dataType: 'json',
-                                        processData: false,
-                                        contentType: 'application/json'
-                                    }).done(function (response) {
-                                        if (nf.Common.isDefinedAndNotNull(response.reportingTask)) {
-                                            // update the revision
-                                            nf.Client.setRevision(response.revision);
-
-                                            // reload the reporting task
-                                            renderReportingTask(response.reportingTask);
-                                            nf.ControllerService.reloadReferencedServices(response.reportingTask);
+                                // save the reporting task
+                                saveReportingTask(reportingTask).done(function (response) {
+                                    // reload the reporting task
+                                    renderReportingTask(response.reportingTask);
+                                    nf.ControllerService.reloadReferencedServices(response.reportingTask);
 
-                                            // close the details panel
-                                            $('#reporting-task-configuration').modal('hide');
-                                        }
-                                    }).fail(handleReportingTaskConfigurationError);
-                                }
+                                    // close the details panel
+                                    $('#reporting-task-configuration').modal('hide');
+                                });
                             }
                         }
                     }, {
@@ -481,29 +529,10 @@ nf.ReportingTask = (function () {
                                         overlayBackground: false,
                                         noHandler: openCustomUi,
                                         yesHandler: function () {
-                                            // marshal the settings and properties and update the reporting task
-                                            var updatedReportingTask = marshalDetails();
-
-                                            // ensure details are valid as far as we can tell
-                                            if (validateDetails(updatedReportingTask)) {
-                                                // update the selected component
-                                                $.ajax({
-                                                    type: 'PUT',
-                                                    data: JSON.stringify(updatedReportingTask),
-                                                    url: reportingTask.uri,
-                                                    dataType: 'json',
-                                                    processData: false,
-                                                    contentType: 'application/json'
-                                                }).done(function (response) {
-                                                    if (nf.Common.isDefinedAndNotNull(response.reportingTask)) {
-                                                        // update the revision
-                                                        nf.Client.setRevision(response.revision);
-
-                                                        // open the custom ui
-                                                        openCustomUi();
-                                                    }
-                                                }).fail(handleReportingTaskConfigurationError);
-                                            }
+                                            saveReportingTask(reportingTask).done(function () {
+                                                // open the custom ui
+                                                openCustomUi();
+                                            });
                                         }
                                     });
                                 } else {