webstaff: Add copy note creation/editing
authorMike Rylander <mrylander@gmail.com>
Wed, 2 Sep 2015 20:12:44 +0000 (16:12 -0400)
committerJason Stephenson <jstephenson@mvlc.org>
Mon, 14 Sep 2015 19:44:18 +0000 (15:44 -0400)
TODO: move copy note dialog to a service so others can use it

Signed-off-by: Mike Rylander <mrylander@gmail.com>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Signed-off-by: Jason Stephenson <jstephenson@mvlc.org>

Open-ILS/src/templates/staff/cat/volcopy/t_attr_edit.tt2
Open-ILS/src/templates/staff/cat/volcopy/t_copy_notes.tt2 [new file with mode: 0644]
Open-ILS/src/templates/staff/cat/volcopy/t_defaults.tt2
Open-ILS/web/js/ui/default/staff/cat/volcopy/app.js

index d427704..9a0b48e 100644 (file)
                         <option value="3">[% l('High') %]</option>
                     </select>
                 </div>
+                <div class="col-md-6">
+                    <button
+                      class="btn btn-default"
+                      ng-disabled="!defaults.copy_notes"
+                      ng-click="copy_notes_dialog(workingGridControls.selectedItems())"
+                      type="button">
+                        [% l('Copy Notes') %]
+                    </button>
+                </div>
             </div>
         </div>
 
diff --git a/Open-ILS/src/templates/staff/cat/volcopy/t_copy_notes.tt2 b/Open-ILS/src/templates/staff/cat/volcopy/t_copy_notes.tt2
new file mode 100644 (file)
index 0000000..7bd26a7
--- /dev/null
@@ -0,0 +1,91 @@
+<form ng-submit="ok(note)" role="form">
+    <div class="modal-header">
+      <button type="button" class="close" ng-click="cancel()" 
+        aria-hidden="true">&times;</button>
+      <h4 class="modal-title">[% l('New Copy Note') %]</h4>
+    </div>
+    <div class="modal-body">
+      <div class="row">
+        <div class="col-md-6">
+          <input class="form-control" type="text"
+            ng-model="note.title" placeholder="[% l('Title...') %]"/>
+        </div>
+        <div class="col-md-3">
+          <label>
+            <input type="checkbox" ng-model="note.pub"/>
+            [% l('Public Note') %]
+          </label>
+        </div>
+      </div>
+      <div class="row pad-vert">
+        <div class="col-md-12">
+          <textarea class="form-control" 
+            ng-model="note.value" placeholder="[% l('Note...') %]">
+          </textarea>
+        </div>
+      </div>
+    </div>
+    <div class="modal-footer">
+      <div class="row">
+        <div class="col-md-2">
+          <input type="text" class="form-control" ng-hide="!require_initials" 
+            ng-model="initials" placeholder="[% l('Initials') %]" ng-required="require_initials"/>
+        </div>
+        <div class="col-md-10 pull-right">
+          <input type="submit" class="btn btn-primary" value="[% l('OK') %]"/>
+          <button class="btn btn-warning" ng-click="cancel($event)">[% l('Cancel') %]</button>
+        </div>
+      </div>
+
+      <div class="row pad-vert" ng-if="note_list.length &gt; 0"> 
+        <div class="col-md-12">
+          <div class="row">
+            <div class="col-md-12">
+              <hr/>
+            </div>
+          </div>
+          <div class="row">
+            <div class="col-md-12">
+              <h4 class="pull-left">[% l('Existing Copy Notes') %]</h4>
+            </div>
+          </div>
+        </div>
+      </div>
+
+      <div class="row" ng-repeat="n in note_list" ng-init="pub = n.pub(); title = n.title(); value = n.value(); deleted = n.isdeleted()">
+        <div class="col-md-12">
+          <div class="row">
+            <div class="col-md-6">
+              <input class="form-control" type="text" ng-change="n.title(title) && n.ischanged(1)"
+                ng-model="title" placeholder="[% l('Title...') %]" ng-disabled="deleted"/>
+            </div>
+            <div class="col-md-3">
+              <label>
+                <input type="checkbox" ng-model="pub" ng-change="n.pub(pub) && n.ischanged(1)" ng-disabled="deleted"/>
+                [% l('Public Note') %]
+              </label>
+            </div>
+            <div class="col-md-3">
+              <label>
+                <input type="checkbox" ng-model="deleted" ng-change="n.isdeleted(deleted)"/>
+                [% l('Deleted?') %]
+              </label>
+            </div>
+          </div>
+          <div class="row pad-vert">
+            <div class="col-md-12">
+              <textarea class="form-control" ng-change="n.value(value) && n.ischanged(1)"
+                ng-model="value" placeholder="[% l('Note...') %]" ng-disabled="deleted">
+              </textarea>
+            </div>
+          </div>
+          <div class="row">
+            <div class="col-md-12">
+              <hr/>
+            </div>
+          </div>
+        </div>
+      </div>
+
+    </div>
+</form>
index f589139..6c356c2 100644 (file)
                     </label>
                 </div>
                 <div class="col-xs-6">
+                    <label>
+                        <input type="checkbox" ng-change="saveDefaults()" ng-model="defaults.copy_notes"/>
+                        [% l('Add/Edit Copy Notes') %]
+                    </label>
                 </div>
             </div>
 
                     </label>
                 </div>
                 <div class="col-xs-6">
-                    <h6>[% l('Statistical Categories') %]</h6>
+                    <label>
+                        <input type="checkbox" ng-change="saveDefaults()" ng-model="defaults.copy_notes_pub"/>
+                        [% l('Copy Notes are Public') %]
+                    </label>
                 </div>
             </div>
 
                     </label>
                 </div>
                 <div class="col-xs-6">
-                    <label>
-                        <eg-org-selector selected="defaults.statcat_filter" noDefault label="[% l('Default Filter Library') %]" disableTest="cant_have_vols"></eg-org-selector>
-                    </label>
+                    <h6>[% l('Statistical Categories') %]</h6>
                 </div>
             </div>
 
                 </div>
                 <div class="col-xs-6">
                     <label>
-                        <input type="checkbox" ng-change="saveDefaults()" ng-model="defaults.statcats"/>
-                        [% l('Edit Statistical Data') %]
+                        <eg-org-selector
+                            selected="defaults.statcat_filter"
+                            noDefault label="[% l('Default Filter Library') %]"
+                            disableTest="cant_have_vols"></eg-org-selector>
                     </label>
                 </div>
             </div>
                     </label>
                 </div>
                 <div class="col-xs-6">
+                    <label>
+                        <input type="checkbox" ng-change="saveDefaults()" ng-model="defaults.statcats"/>
+                        [% l('Edit Statistical Data') %]
+                    </label>
                 </div>
             </div>
 
index 87f734a..638a77f 100644 (file)
@@ -153,7 +153,7 @@ function(egCore , $q) {
     service.flesh = {   
         flesh : 3, 
         flesh_fields : {
-            acp : ['call_number','parts','stat_cat_entries'],
+            acp : ['call_number','parts','stat_cat_entries', 'notes'],
             acn : ['label_class','prefix','suffix']
         }
     }
@@ -499,11 +499,12 @@ function(egCore , $q) {
  * Edit controller!
  */
 .controller('EditCtrl', 
-       ['$scope','$q','$window','$routeParams','$location','$timeout','egCore','egNet','egGridDataProvider','itemSvc',
-function($scope , $q , $window , $routeParams , $location , $timeout , egCore , egNet , egGridDataProvider , itemSvc) {
+       ['$scope','$q','$window','$routeParams','$location','$timeout','egCore','egNet','egGridDataProvider','itemSvc','$modal',
+function($scope , $q , $window , $routeParams , $location , $timeout , egCore , egNet , egGridDataProvider , itemSvc , $modal) {
 
     $scope.defaults = { // If defaults are not set at all, allow everything
         statcats : true,
+        copy_notes : true,
         attributes : {
             status : true,
             loan_duration : true,
@@ -1048,7 +1049,6 @@ function($scope , $q , $window , $routeParams , $location , $timeout , egCore ,
                 'open-ils.cat.asset.volume.fleshed.batch.update.override',
                 egCore.auth.token(), cnList, 1, { auto_merge_vols : 1, create_parts : 1 }
             ).then(function(update_count) {
-                alert(update_count + ' call numbers updated');
                 if (and_exit) {
                     $scope.dirty = false;
                     $timeout(function(){$window.close()});
@@ -1062,6 +1062,60 @@ function($scope , $q , $window , $routeParams , $location , $timeout , egCore ,
 
     }
 
+    $scope.copy_notes_dialog = function(copy_list) {
+        var default_pub = Boolean($scope.defaults.copy_notes_pub);
+        if (!angular.isArray(copy_list)) copy_list = [copy_list];
+
+        return $modal.open({
+            templateUrl: './cat/volcopy/t_copy_notes',
+            animation: true,
+            controller:
+                   ['$scope','$modalInstance',
+            function($scope , $modalInstance) {
+                $scope.focusNote = true;
+                $scope.note = {
+                    creator : egCore.auth.user().id(),
+                    title   : '',
+                    value   : '',
+                    pub     : default_pub,
+                };
+
+                $scope.require_initials = false;
+                egCore.org.settings([
+                    'ui.staff.require_initials.copy_notes'
+                ]).then(function(set) {
+                    $scope.require_initials = Boolean(set['ui.staff.require_initials.copy_notes']);
+                });
+
+                $scope.note_list = [];
+                if (copy_list.length == 1) {
+                    $scope.note_list = copy_list[0].notes();
+                }
+
+                $scope.ok = function(note) {
+
+                    if (note.initials) note.value += ' [' + note.initials + ']';
+                    angular.forEach(copy_list, function (cp) {
+                        var n = new egCore.idl.acpn();
+                        n.creator(note.creator);
+                        n.pub(note.pub);
+                        n.title(note.title);
+                        n.value(note.value);
+                        n.owning_copy(cp.id());
+                        cp.notes().push( n );
+                    });
+
+                    $modalInstance.close();
+                }
+
+                $scope.cancel = function($event) {
+                    $modalInstance.dismiss();
+                    $event.preventDefault();
+                }
+            }]
+        });
+    }
+
 }])
 
 .directive("egVolTemplate", function () {
@@ -1075,6 +1129,7 @@ function($scope , $q , $window , $routeParams , $location , $timeout , egCore ,
 
                 $scope.defaults = { // If defaults are not set at all, allow everything
                     statcats : true,
+                    copy_notes : true,
                     attributes : {
                         status : true,
                         loan_duration : true,