Skip to content

Commit

Permalink
#1644 add sub data sets to edit dialogs
Browse files Browse the repository at this point in the history
  • Loading branch information
René Reitmann committed Oct 23, 2018
1 parent 70bd157 commit e0f6f67
Show file tree
Hide file tree
Showing 14 changed files with 245 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public class DataSet extends AbstractRdcDomainObject {
@I18nStringSize(max = StringLengths.LARGE,
message = "data-set-management.error.data-set.description.i18n-string-size")
@I18nStringNotEmpty(
message = "data-set-management.error.data-set.description." + "i18n-string-not-empty")
message = "data-set-management.error.data-set.description.i18n-string-not-empty")
private I18nString description;

@NotNull(message = "data-set-management.error.data-set.number.not-null")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ angular.module('metadatamanagementApp').factory('ToolbarHeaderService',
dataSetItem.tooltip = translationStringsMap
.dataSetDetail.translateString;
dataSetItem.number = dataSet.dataSetNumber;
dataSetItem.enableLastItem = dataSet.enableLastItem;
} else {
dataSetItem.notFound = '?';
}
Expand Down Expand Up @@ -324,6 +325,20 @@ angular.module('metadatamanagementApp').factory('ToolbarHeaderService',
$rootScope.toolbarHeaderItems.push(searchItem.get(), studyItem,
surveyItem, dataSetItem);
break;
case 'dataSetEdit':
dataSetItem = createRelatedDataSetItem(item);
surveyItem = createRelatedSurveyItem([], 'data-set',
item.id);
$rootScope.toolbarHeaderItems.push(searchItem.get(), studyItem,
surveyItem, dataSetItem);
break;
case 'dataSetCreate':
dataSetItem = createRelatedDataSetItem(item);
surveyItem = createRelatedSurveyItem([], 'data-set',
item.id);
$rootScope.toolbarHeaderItems.push(searchItem.get(), studyItem,
surveyItem, dataSetItem);
break;
case 'instrumentDetail':
instrumentItem = createRelatedInstrumentItem(item, 'instrument');
surveyItem = createRelatedSurveyItem(item.surveys, 'instrument',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,8 @@ angular.module('metadatamanagementApp').config(
'pattern': 'Die FDZ-ID darf nur alphanumerische Zeichen, deutsche Umlaute, Ausrufezeichen und ß beinhalten.'
},
'description': {
'i18n-string-size': 'Die Maximallänge der Datensatzbeschreibung ist 2048 Zeichen.'
'i18n-string-size': 'Die Maximallänge der Datensatzbeschreibung ist 2048 Zeichen.',
'i18n-string-not-empty': 'Die Datensatzbeschreibung muss in mindestens einer Sprache angegeben werden.'
},
'annotations': {
'i18n-string-size': 'Die Maximallänge der Anmerkungen ist 2048 Zeichen.'
Expand All @@ -131,7 +132,7 @@ angular.module('metadatamanagementApp').config(
}
},
'survey-numbers': {
'not-empty': 'Der Datensatz muss mindestens eine Erhebungsnummer beinhalten!'
'not-empty': 'Der Datensatz muss mindestens einer Erhebung zugeordnet sein!'
},
'number': {
'not-null': 'Die Nummer des Datensatzes darf nicht leer sein!'
Expand Down Expand Up @@ -182,22 +183,22 @@ angular.module('metadatamanagementApp').config(
},
'sub-data-set': {
'name': {
'not-empty': 'Der Name des {{index}}. Sub-Daten-Satzes darf bei dem Datensatz nicht leer sein!',
'size': 'Die Maximallänge des Namens des {{index}}. Sub-Daten-Satzes ist 32 Zeichen.'
'not-empty': 'Der Name eines Subdatensatz darf nicht leer sein!',
'size': 'Die Maximallänge des Namens eines Subdatensatz ist 32 Zeichen.'
},
'description': {
'i18n-string-not-empty': 'Die Beschreibung des {{index}}. Sub-Daten-Satzes darf nicht leer sein!',
'i18n-string-size': 'Die Maximallänge der Beschreibung des {{index}}. Sub-Daten-Satzes ist 512 Zeichen.'
'i18n-string-not-empty': 'Die Beschreibung eines Subdatensatz darf nicht leer sein!',
'i18n-string-size': 'Die Maximallänge der Beschreibung eines Subdatensatz ist 512 Zeichen.'
},
'citation-hint': {
'i18n-string-size': 'Die Maximallänge des Zitationshinweises eines Subdatensatzes ist 2048 Zeichen.'
},
'access-way': {
'not-null': 'Der Zugangsweg des {{index}}. Sub-Daten-Satzes darf nicht leer sein!',
'valid-access-way': 'Der Zugangsweg des {{index}}. Sub-Daten-Satzes ist ungültig. Erlaubt sind nur: download-cuf, download-suf, remote-desktop-suf oder onsite-suf.'
'not-null': 'Der Zugangsweg eines Subdatensatz darf nicht leer sein!',
'valid-access-way': 'Der Zugangsweg eines Subdatensatz ist ungültig. Erlaubt sind nur: download-cuf, download-suf, remote-desktop-suf oder onsite-suf.'
},
'number-of-observations': {
'not-null': 'Die Anzahl von Beobachtungen darf bei einem Sub-Daten-Satzes nicht leer sein!'
'not-null': 'Die Anzahl von Fälle/Episoden darf bei einem Subdatensatz nicht leer sein!'
}
},
'post-validation': {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,8 @@ angular.module('metadatamanagementApp').config(
'pattern': 'Use only alphanumeric signs, german umlauts, ß and space, underscore, exclamation sign and minus for the RDC-ID.'
},
'description': {
'i18n-string-size': 'The max length of the description is 2048 signs.'
'i18n-string-size': 'The max length of the description is 2048 signs.',
'i18n-string-not-empty': 'The description must be specified in at least one language'
},
'annotations': {
'i18n-string-size': 'The max length of the annotations is 2048 signs.'
Expand All @@ -131,7 +132,7 @@ angular.module('metadatamanagementApp').config(
}
},
'survey-numbers': {
'not-empty': 'The Data Set must contain at least one Survey Number!'
'not-empty': 'The Data Set must be assigned to at least one survey!'
},
'number': {
'not-null': 'The Number of the Data Set must not be empty!'
Expand All @@ -150,7 +151,7 @@ angular.module('metadatamanagementApp').config(
},
'type': {
'valid-type': 'The value of Data Set Type is invalid. Valid english values are: Individual Data or Spell Data. The type might be invalid in other languagses.',
'not-null': 'The Type Set must not be empty!'
'not-null': 'The Type of a Data Set must not be empty!'
}
},
'data-set-attachment-metadata': {
Expand Down Expand Up @@ -182,22 +183,22 @@ angular.module('metadatamanagementApp').config(
},
'sub-data-set': {
'name': {
'not-empty': 'The Name of the {{index}}. Sub Data Set must not be empty!',
'size': 'The max length of the Name the {{index}}. Sub Data Set is 32 signs.'
'not-empty': 'The Name of a Sub Data Set must not be empty!',
'size': 'The max length of the Name of a Sub Data Set is 32 signs.'
},
'description': {
'i18n-string-not-empty': 'The Description of the {{index}}. Sub Data Set must not be empty!',
'i18n-string-size': 'The max length of the Name of the {{index}}. Sub Data Set is 32 signs.'
'i18n-string-not-empty': 'The Description a Sub Data Set must not be empty!',
'i18n-string-size': 'The max length of the Description of a Sub Data Set is 32 signs.'
},
'citation-hint': {
'i18n-string-size': 'The max length of the citation hint of the Sub Data Set is 2048.'
'i18n-string-size': 'The max length of the citation hint of a Sub Data Set is 2048.'
},
'access-way': {
'not-null': 'The value of Access Way of the {{index}}. Sub Data Set must not be empty!',
'valid-access-way': 'The value of Access Way of the {{index}}. Sub Data Set is invalid. Valid values are: download-cuf, download-suf, remote-desktop-suf or onsite-suf.'
'not-null': 'The value of Access Way of a Sub Data Set must not be empty!',
'valid-access-way': 'The value of Access Way of a Sub Data Set is invalid. Valid values are: download-cuf, download-suf, remote-desktop-suf or onsite-suf.'
},
'number-of-observations': {
'not-null': 'The number of observations of a Sub Data Set must not be empty!'
'not-null': 'The number of observations/episodes of a Sub Data Set must not be empty!'
}
},
'post-validation': {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ angular.module('metadatamanagementApp')
function(entity, PageTitleService, $timeout,
$state, ToolbarHeaderService, Principal, SimpleMessageToastService,
CurrentProjectService, DataSetIdBuilderService, DataSetResource,
$scope, SurveyIdBuilderService,
$scope, SurveyIdBuilderService, $document,
ElasticSearchAdminService, $mdDialog, $transitions, StudyResource,
CommonDialogsService, LanguageService, AvailableDataSetNumbersResource,
DataSetAttachmentResource, $q, StudyIdBuilderService, SearchDao,
Expand Down Expand Up @@ -120,6 +120,9 @@ angular.module('metadatamanagementApp')
studyId: StudyIdBuilderService.buildStudyId(
CurrentProjectService.getCurrentProject().id
),
subDataSets: [{
name: ''
}]
});
updateToolbarHeaderAndPageTitle();
$scope.registerConfirmOnDirtyHook();
Expand All @@ -145,7 +148,10 @@ angular.module('metadatamanagementApp')
CurrentProjectService.getCurrentProject().id,
studyId: StudyIdBuilderService.buildStudyId(
CurrentProjectService.getCurrentProject().id
)
),
subDataSets: [{
name: ''
}]
});
$scope.responseRateInitializing = true;
updateToolbarHeaderAndPageTitle();
Expand All @@ -167,6 +173,75 @@ angular.module('metadatamanagementApp')
}
};

ctrl.allAccessWays = ['download-cuf', 'download-suf',
'remote-desktop-suf', 'onsite-suf'];
$scope.$watch('ctrl.dataSet.subDataSets', function() {
if (ctrl.dataSet) {
ctrl.availableAccessWays = ctrl.allAccessWays.slice();
ctrl.dataSet.subDataSets.forEach(function(subDataSet) {
_.remove(ctrl.availableAccessWays, function(availableAccessWay) {
return availableAccessWay === subDataSet.accessWay;
});
});
}
}, true);

ctrl.deleteSubDataSet = function(index) {
ctrl.dataSet.subDataSets.splice(index, 1);
$scope.dataSetForm.$setDirty();
};

ctrl.addSubDataSet = function() {
ctrl.dataSet.subDataSets.push({
name: ''
});
$timeout(function() {
$document.find('input[name="subDataSetsName_' +
(ctrl.dataSet.subDataSets.length - 1) + '"]')
.focus();
});
};

ctrl.setCurrentSubDataSet = function(index, event) {
ctrl.currentSubDataSetInputName = event.target.name;
ctrl.currentSubDataSetIndex = index;
};

ctrl.deleteCurrentSubDataSet = function(event) {
if (event.relatedTarget && (
event.relatedTarget.id === 'move-sub-data-set-up-button' ||
event.relatedTarget.id === 'move-sub-data-set-down-button')) {
return;
}
delete ctrl.currentSubDataSetIndex;
};

ctrl.moveCurrentSubDataSetUp = function() {
var a = ctrl.dataSet.subDataSets[ctrl.currentSubDataSetIndex - 1];
ctrl.dataSet.subDataSets[ctrl.currentSubDataSetIndex - 1] =
ctrl.dataSet.subDataSets[ctrl.currentSubDataSetIndex];
ctrl.dataSet.subDataSets[ctrl.currentSubDataSetIndex] = a;
ctrl.currentSubDataSetInputName = ctrl.currentSubDataSetInputName
.replace('_' + ctrl.currentSubDataSetIndex,
'_' + (ctrl.currentSubDataSetIndex - 1));
$document.find('*[name="' + ctrl.currentSubDataSetInputName + '"]')
.focus();
$scope.dataSetForm.$setDirty();
};

ctrl.moveCurrentSubDataSetDown = function() {
var a = ctrl.dataSet.subDataSets[ctrl.currentSubDataSetIndex + 1];
ctrl.dataSet.subDataSets[ctrl.currentSubDataSetIndex + 1] =
ctrl.dataSet.subDataSets[ctrl.currentSubDataSetIndex];
ctrl.dataSet.subDataSets[ctrl.currentSubDataSetIndex] = a;
ctrl.currentSubDataSetInputName = ctrl.currentSubDataSetInputName
.replace('_' + ctrl.currentSubDataSetIndex,
'_' + (ctrl.currentSubDataSetIndex + 1));
$document.find('*[name="' + ctrl.currentSubDataSetInputName + '"]')
.focus();
$scope.dataSetForm.$setDirty();
};

ctrl.saveDataSet = function() {
if ($scope.dataSetForm.$valid) {
ctrl.dataSet.$save()
Expand Down

0 comments on commit e0f6f67

Please sign in to comment.