1 angular.module('egAdminConfig',
2 ['ngRoute','ui.bootstrap','egCoreMod','egUiMod','egGridMod','egFmRecordEditorMod'])
4 .controller('MarcField',
5 ['$scope','$q','$timeout','$location','$window','$uibModal','egCore','egGridDataProvider',
7 function($scope , $q , $timeout , $location , $window , $uibModal , egCore , egGridDataProvider ,
10 egCore.startup.go(); // standalone mode requires manual startup
12 $scope.marc_record_type = 'biblio';
13 $scope.$watch('marc_record_type', function(newVal, oldVal) {
14 if (newVal != oldVal) {
15 $scope.gridControls.setQuery(generateQuery($scope.marc_record_type));
16 $scope.gridControls.refresh();
20 $scope.new_record = function() {
24 $scope.edit_record = function(items) {
25 if (items.length != 1) return;
26 spawn_editor(items[0].id);
29 spawn_editor = function(id) {
31 if (arguments.length == 1) {
32 templ = '<eg-edit-fm-record idl-class="cmrcfld" mode="update" record-id="id" on-save="ok" on-cancel="cancel"></eg-edit-fm-record>';
34 templ = '<eg-edit-fm-record idl-class="cmrcfld" mode="create" on-save="ok" on-cancel="cancel"></eg-edit-fm-record>';
36 gridControls = $scope.gridControls;
41 '$scope', '$uibModalInstance',
42 function($scope , $uibModalInstance) {
45 $scope.ok = function($event) {
46 $uibModalInstance.close();
47 gridControls.refresh();
50 $scope.cancel = function($event) {
51 $uibModalInstance.dismiss();
58 $scope.delete_record = function(selected) {
59 if (!selected || !selected.length) return;
61 egCore.pcrud.retrieve('cmrcfld', selected[0].id).then(function(rec) {
63 egCore.strings.EG_CONFIRM_DELETE_RECORD_TITLE,
64 egCore.strings.EG_CONFIRM_DELETE_RECORD_BODY,
65 { id : rec.id() } // TODO replace with selector if available?
66 ).result.then(function() {
67 egCore.pcrud.remove(rec).then(function() {
68 $scope.gridControls.refresh();
74 function generateQuery(marc_record_type) {
76 'id' : { '!=' : null },
77 'marc_record_type' : marc_record_type
81 $scope.gridControls = {
82 setQuery : function() {
83 return generateQuery($scope.marc_record_type);
85 setSort : function() {