1 angular.module('egSerialsAppDep')
3 .directive('egMfhdManager', function() {
10 templateUrl: './serials/t_mfhd_manager',
12 ['$scope','$q','egSerialsCoreSvc','egCore','egGridDataProvider',
13 '$uibModal','$timeout','egMfhdCreateDialog','egConfirmDialog',
14 function($scope , $q , egSerialsCoreSvc , egCore , egGridDataProvider ,
15 $uibModal , $timeout , egMfhdCreateDialog , egConfirmDialog) {
18 egSerialsCoreSvc.fetch_mfhds($scope.bibId).then(function() {
19 $scope.mfhdGridDataProvider.refresh();
24 $scope.mfhdGridControls = {
25 activateItem : function (item) { } // TODO
27 $scope.mfhdGridDataProvider = egGridDataProvider.instance({
28 get : function(offset, count) {
29 return this.arrayNotifier(egSerialsCoreSvc.flatMfhdList, offset, count);
32 $scope.need_one_selected = function() {
33 var items = $scope.mfhdGridControls.selectedItems();
34 if (items.length == 1) return false;
38 $scope.createMfhd = function() {
39 egMfhdCreateDialog.open($scope.bibId).result.then(function() {
44 $scope.edit_mfhd = function() {
45 var items = $scope.mfhdGridControls.selectedItems();
46 if (items.length != 1) return;
48 'marc_xml' : items[0].marc_xml
51 templateUrl: './share/t_edit_mfhd',
55 ['$scope', '$uibModalInstance', function($scope, $uibModalInstance) {
56 $scope.focusMe = true;
58 $scope.dirty_flag = false;
59 $scope.ok = function() { $uibModalInstance.close($scope.args) }
60 $scope.cancel = function () { $uibModalInstance.dismiss() }
62 }).result.then(function (args) {
63 egCore.pcrud.retrieve('sre', items[0].id).then(function(sre) {
64 sre.marc(args.marc_xml);
65 egCore.pcrud.update(sre).then(function() {
72 $scope.delete_mfhds = function() {
73 var items = $scope.mfhdGridControls.selectedItems();
74 if (items.length <= 0) return;
77 egCore.strings.CONFIRM_DELETE_MFHDS,
78 egCore.strings.CONFIRM_DELETE_MFHDS_MESSAGE,
79 {items : items.length}
80 ).result.then(function () {
82 angular.forEach(items, function(mfhd) {
83 var promise = $q.defer();
84 promises.push(promise.promise);
85 egCore.pcrud.retrieve('sre', mfhd.id).then(function(sre) {
86 egCore.pcrud.remove(sre).then(function() {
91 $q.all(promises).then(function() {