← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 13101: implemented save functionality in ip feed UI (save not implemented in controller yet)

 

------------------------------------------------------------
revno: 13101
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2013-12-02 14:59:00 +0100
message:
  implemented save functionality in ip feed UI (save not implemented in controller yet)
modified:
  dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/resources/org/hisp/dhis/dashboard/i18n_module.properties
  dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/interpretationFeed.vm
  dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/javascript/interpretation.js


--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk

Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/resources/org/hisp/dhis/dashboard/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/resources/org/hisp/dhis/dashboard/i18n_module.properties	2013-12-01 16:26:11 +0000
+++ dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/resources/org/hisp/dhis/dashboard/i18n_module.properties	2013-12-02 13:59:00 +0000
@@ -121,3 +121,4 @@
 add_items_to_current_dashboard=Add items to current dashboard
 could_not_delete_interpretation=Could not delete interpretation, please try again later
 could_not_delete_interpretation_comment=Could not delete interpretation comment, please try again later
+could_not_save_interpretation=Could not save interpretation, please try again later
\ No newline at end of file

=== modified file 'dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/interpretationFeed.vm'
--- dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/interpretationFeed.vm	2013-12-02 13:47:39 +0000
+++ dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/interpretationFeed.vm	2013-12-02 13:59:00 +0000
@@ -13,6 +13,9 @@
 <script>
 var i18n_cancel = '$encoder.jsEscape( $i18n.getString( "cancel" ) , "'")';
 var i18n_save = '$encoder.jsEscape( $i18n.getString( "save" ) , "'")';
+var i18n_could_not_delete_interpretation_comment = '$encoder.jsEscape( $i18n.getString( "could_not_delete_interpretation_comment" ) , "'")';
+var i18n_could_not_delete_interpretation = '$encoder.jsEscape( $i18n.getString( "could_not_delete_interpretation" ) , "'")';
+var i18n_could_not_save_interpretation = '$encoder.jsEscape( $i18n.getString( "could_not_save_interpretation" ) , "'")';
 
 jQuery(function() {
   var dropDown = jQuery('.dropDown');

=== modified file 'dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/javascript/interpretation.js'
--- dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/javascript/interpretation.js	2013-12-02 13:47:39 +0000
+++ dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/javascript/interpretation.js	2013-12-02 13:59:00 +0000
@@ -128,7 +128,31 @@
   var saveButton = jQuery("<button/>")
     .text(i18n_save)
     .on('click', function( e ) {
-      alert('save is not implemented');
+      var content = textArea.html().trim();
+
+      if( ipCommentUid ) {
+        $.ajax({
+          url: '../api/interpretations/' + ipUid + '/comments/' + ipCommentUid,
+          contentType: 'text/plain; charset=UTF-8',
+          type: 'POST',
+          data: content
+        }).done(function() {
+          $target.html(content);
+        }).error(function() {
+          setHeaderDelayMessage(i18n_could_not_save_interpretation);
+        });
+      } else {
+        $.ajax({
+          url: '../api/interpretations/' + ipUid,
+          contentType: 'text/plain; charset=UTF-8',
+          type: 'POST',
+          data: content
+        }).done(function() {
+          $target.html(content);
+        }).error(function() {
+          setHeaderDelayMessage(i18n_could_not_save_interpretation);
+        });
+      }
     });
 
   container.append(cancelButton);
@@ -156,7 +180,7 @@
     }).done(function() {
       jqInterpretation.remove();
     }).error(function() {
-      setHeaderDelayMessage('$i18n.getString("could_not_delete_interpretation")');
+      setHeaderDelayMessage(i18n_could_not_delete_interpretation);
     });
   } else if( isComment ) {
     jQuery.ajax({
@@ -165,7 +189,7 @@
     }).done(function() {
       jqInterpretationComment.remove();
     }).error(function() {
-      setHeaderDelayMessage('$i18n.getString("could_not_delete_interpretation_comment")');
+      setHeaderDelayMessage(i18n_could_not_delete_interpretation_comment);
     });
   }
 }