--- /dev/null
+<form ng-submit="ok(note)" role="form">
+ <div class="modal-header">
+ <button type="button" class="close" ng-click="cancel()"
+ aria-hidden="true">×</button>
+ <h4 class="modal-title">[% l('Apply Copy Tags') %]</h4>
+ </div>
+ <div class="modal-body">
+ <ul>
+ <li ng-repeat="map in tag_map" ng-show="!map.isdeleted()">
+ <span class="copy_tag_label">{{map.tag().label()}}</span>
+ <button type="button" ng-click="map.isdeleted(1)" class="btn btn-xs btn-warning">[% ('Remove') %]</button>
+ </li>
+ </ul>
+ <div class="row">
+ <div class="col-md-12 form-inline">
+ <div class="form-group">
+ <label for="tagType">[% l('Tag Type') %]</label>
+ <select class="form-control" name="tagType" ng-model="tag_type"
+ ng-options="t.code() as t.label() for t in tag_types"></select>
+ </div>
+ <div class="form-group">
+ <label for="tagLabel">[% l('Tag') %]</label>
+ <input name="tabLabel" type="text" ng-model="selectedLabel" placeholder="[% l('Enter tag label...') %]"
+ uib-typeahead="tag for tag in getTags($viewValue)" typeahead-editable="false"
+ class="form-control"></input>
+ </div>
+ <button type="button" class="btn btn-sm btn-default" ng-click="addTag()">[% l('Add Tag') %]</button>
+ </div>
+ </div>
+ </div>
+ <div class="modal-footer">
+ <div class="row">
+ <div class="col-md-12 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>
+</form>
}
}
+ $scope.applyTags = function(copies) {
+ return $uibModal.open({
+ templateUrl: './cat/bucket/copy/t_apply_tags',
+ animation: true,
+ controller:
+ ['$scope','$uibModalInstance',
+ function($scope , $uibModalInstance) {
+
+ $scope.tag_map = [];
+
+ egCore.pcrud.retrieveAll('cctt', {order_by : { cctt : 'label' }}, {atomic : true}).then(function(list) {
+ $scope.tag_types = list;
+ $scope.tag_type = $scope.tag_types[0].code(); // just pick a default
+ });
+
+ $scope.getTags = function(val) {
+ return egCore.pcrud.search('acpt',
+ {
+ owner : egCore.org.fullPath(egCore.auth.user().ws_ou(), true),
+ label : { 'startwith' : {
+ transform: 'evergreen.lowercase',
+ value : [ 'evergreen.lowercase', val ]
+ }},
+ tag_type : $scope.tag_type
+ },
+ { order_by : { 'acpt' : ['label'] } }, { atomic: true }
+ ).then(function(list) {
+ return list.map(function(item) {
+ return item.label();
+ });
+ });
+ }
+
+ $scope.addTag = function() {
+ var tagLabel = $scope.selectedLabel;
+ // clear the typeahead
+ $scope.selectedLabel = "";
+
+ egCore.pcrud.search('acpt',
+ {
+ owner : egCore.org.fullPath(egCore.auth.user().ws_ou(), true),
+ label : tagLabel,
+ tag_type : $scope.tag_type
+ },
+ { order_by : { 'acpt' : ['label'] } }, { atomic: true }
+ ).then(function(list) {
+ if (list.length > 0) {
+ var newMap = new egCore.idl.acptcm();
+ newMap.isnew(1);
+ newMap.tag(egCore.idl.Clone(list[0]));
+ $scope.tag_map.push(newMap);
+ }
+ });
+ }
+
+ $scope.ok = function() {
+ var promises = [];
+ angular.forEach($scope.tag_map, function(map) {
+ if (map.isdeleted()) return;
+ angular.forEach(copies, function (cp) {
+ var m = new egCore.idl.acptcm();
+ m.isnew(1);
+ m.copy(cp.id);
+ m.tag(map.tag().id());
+ promises.push(egCore.pcrud.create(m));
+ });
+ });
+ return $q.all(promises).then(function(){$uibModalInstance.close()});
+ }
+
+ $scope.cancel = function($event) {
+ $uibModalInstance.dismiss();
+ $event.preventDefault();
+ }
+ }]
+ });
+ }
+
// fetch the bucket; on error show the not-allowed message
if ($scope.bucketId)
drawBucket()['catch'](function() { $scope.forbidden = true });