Compare commits

...

3 Commits

2 changed files with 19 additions and 5 deletions
@@ -15,6 +15,10 @@
}); });
} }
$scope.canAdd = function () {
return !$scope.model.docTypes || !$scope.model.value || $scope.model.value.length < $scope.model.docTypes.length;
}
$scope.remove = function (index) { $scope.remove = function (index) {
$scope.model.value.splice(index, 1); $scope.model.value.splice(index, 1);
} }
@@ -58,9 +62,19 @@
ncResources.getContentTypes().then(function (docTypes) { ncResources.getContentTypes().then(function (docTypes) {
$scope.model.docTypes = docTypes; $scope.model.docTypes = docTypes;
// Count doctype name occurrences
var docTypeNameOccurrences = _.countBy(docTypes, 'name');
// Populate document type tab dictionary // Populate document type tab dictionary
// And append alias to name if multiple doctypes have the same name
docTypes.forEach(function (value) { docTypes.forEach(function (value) {
$scope.docTypeTabs[value.alias] = value.tabs; $scope.docTypeTabs[value.alias] = value.tabs;
value.displayName = value.name;
if (docTypeNameOccurrences[value.name] > 1) {
value.displayName += " (" + value.alias + ")";
}
}); });
}); });
@@ -23,7 +23,7 @@
</td> </td>
<td> <td>
<select id="{{model.alias}}_doctype_select" <select id="{{model.alias}}_doctype_select"
ng-options="dt.alias as dt.name for dt in selectableDocTypesFor(config) | orderBy: 'name'" ng-options="dt.alias as dt.displayName for dt in selectableDocTypesFor(config) | orderBy: 'name'"
ng-model="config.ncAlias" required></select> ng-model="config.ncAlias" required></select>
</td> </td>
<td> <td>
@@ -35,17 +35,17 @@
<input type="text" ng-model="config.nameTemplate" /> <input type="text" ng-model="config.nameTemplate" />
</td> </td>
<td> <td>
<a class="btn btn-danger" ng-click="remove($index)"> <button type="button" class="btn btn-danger" ng-click="remove($index)">
<localize key="general_delete">Delete</localize> <localize key="general_delete">Delete</localize>
</a> </button>
</td> </td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
<div> <div>
<a class="btn" ng-click="add()"> <button type="button" class="btn" ng-click="add()" ng-disabled="!canAdd()">
<localize key="general_add">Add</localize> <localize key="general_add">Add</localize>
</a> </button>
<i class="icon icon-help-alt medium umb-nested-content__help-icon" ng-click="showHelpText = !showHelpText"></i> <i class="icon icon-help-alt medium umb-nested-content__help-icon" ng-click="showHelpText = !showHelpText"></i>
</div> </div>
</div> </div>