<div class="pad-vert">
<button class="btn btn-warning" ng-click="startNewScap()">[% l('Add New') %]</button>
<button class="btn btn-warning" ng-click="importScapFromBibRecord()">[% l('Import from Bibliographic and/or MFHD Records') %]</button>
+ <button class="btn btn-warning" ng-click="importScapFromSpt()">[% l('Create from Template') %]</button>
+ <select ng-model="active_pattern_template.id" ng-options="spt as spt.name for spt in pattern_templates track by spt.id">
+ </select>
</div>
<div class="row" ng-if="new_prediction">
<ng-form name="new_prediction.predform" class="form-inline">
<option value="supplement">[% l('Supplement') %]</option>
<option value="index">[% l('Index') %]</option>
</select>
- <button class="btn btn-default" ng-click="openPatternEditorDialog(new_prediction)">[% l('Create Pattern') %]</button>
+ <button class="btn btn-default" ng-if="new_prediction.pattern_code === null"
+ ng-click="openPatternEditorDialog(new_prediction)">[% l('Create Pattern') %]</button>
+ <button class="btn btn-default" ng-if="new_prediction.pattern_code !== null"
+ ng-click="openPatternEditorDialog(new_prediction)">[% l('Edit Pattern') %]</button>
</div>
<div>
<button type="submit" class="btn btn-default" ng-click="cancelNewScap()">[% l('Cancel') %]</button>
function reload(ssubId) {
var ssub = egSerialsCoreSvc.get_ssub(ssubId);
$scope.predictions = egCore.idl.toTypedHash(ssub.scaps());
+ egSerialsCoreSvc.fetch_spt().then(function() {
+ $scope.pattern_templates = egCore.idl.toTypedHash(egSerialsCoreSvc.sptList);
+ $scope.active_pattern_template = { id : null };
+ if ($scope.pattern_templates.length > 0) {
+ $scope.active_pattern_template.id = $scope.pattern_templates[0].id;
+ }
+ });
}
$scope.$watch('ssubId', function(newVal, oldVal) {
$scope.new_prediction.active = true;
$scope.new_prediction.create_date = new Date();
$scope.new_prediction.subscription = $scope.ssubId;
+ $scope.new_prediction.pattern_code = null;
}
$scope.importScapFromBibRecord = function() {
}
+
+ $scope.importScapFromSpt = function() {
+ $scope.new_prediction = egCore.idl.toTypedHash(new egCore.idl.scap());
+ $scope.new_prediction.type = 'basic';
+ $scope.new_prediction.active = true;
+ $scope.new_prediction.create_date = new Date();
+ $scope.new_prediction.subscription = $scope.ssubId;
+ for (var i = 0; i < $scope.pattern_templates.length; i++) {
+ if ($scope.pattern_templates[i].id == $scope.active_pattern_template.id) {
+ $scope.new_prediction.pattern_code = $scope.pattern_templates[i].pattern_code;
+ break;
+ }
+ }
+ }
$scope.openPatternEditorDialog = function(pred) {
$uibModal.open({
bibId : null,
subId : null,
subTree : [],
- subList : []
+ subList : [],
+ sptList : []
};
// fetch subscription, distributions, streams, captions,
}
}
+ service.fetch_spt = function() {
+ return egCore.net.request(
+ 'open-ils.serial',
+ 'open-ils.serial.pattern_template.retrieve.at.atomic',
+ egCore.auth.token(),
+ egCore.auth.user().ws_ou()
+ ).then(function(list) {
+ service.sptList.length = 0;
+ angular.extend(service.sptList, list);
+ });
+ }
+
return service;
}]);