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',
54 ['$scope', '$uibModalInstance', function($scope, $uibModalInstance) {
55 $scope.focusMe = true;
57 $scope.dirty_flag = false;
58 $scope.ok = function() { $uibModalInstance.close($scope.args) }
59 $scope.cancel = function () { $uibModalInstance.dismiss() }
61 }).result.then(function (args) {
62 egCore.pcrud.retrieve('sre', items[0].id).then(function(sre) {
63 sre.marc(args.marc_xml);
64 egCore.pcrud.update(sre).then(function() {
71 $scope.delete_mfhds = function() {
72 var items = $scope.mfhdGridControls.selectedItems();
73 if (items.length <= 0) return;
76 egCore.strings.CONFIRM_DELETE_MFHDS,
77 egCore.strings.CONFIRM_DELETE_MFHDS_MESSAGE,
78 {items : items.length}
79 ).result.then(function () {
81 angular.forEach(items, function(mfhd) {
82 var promise = $q.defer();
83 promises.push(promise.promise);
84 egCore.pcrud.retrieve('sre', mfhd.id).then(function(sre) {
85 egCore.pcrud.remove(sre).then(function() {
90 $q.all(promises).then(function() {