Simplify radiobuttonlist prevalue editor
This commit is contained in:
committed by
Emma L Garland
parent
1f97c62a1b
commit
65321e8f68
@@ -1,8 +1,13 @@
|
||||
<div class="umb-checkboxlist-preval" ng-controller="Umbraco.PrevalueEditors.CheckboxListController as vm">
|
||||
<div class="umb-checkboxlist-preval" ng-controller="Umbraco.PrevalueEditors.CheckboxListController as vm">
|
||||
|
||||
<ul class="unstyled">
|
||||
<ul class="unstyled" ng-if="vm.viewItems.length">
|
||||
<li ng-repeat="item in vm.viewItems track by $id(item)">
|
||||
<umb-checkbox value="{{item.value}}" model="item.checked" text="{{item.label}}" on-change="vm.change(model, value)"></umb-checkbox>
|
||||
<umb-checkbox
|
||||
value="{{item.value}}"
|
||||
model="item.checked"
|
||||
text="{{item.label}}"
|
||||
on-change="vm.change(model, value)">
|
||||
</umb-checkbox>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
angular.module("umbraco").controller("Umbraco.PrevalueEditors.RadiobuttonListController",
|
||||
function ($scope) {
|
||||
|
||||
var vm = this;
|
||||
|
||||
vm.configItems = [];
|
||||
vm.viewItems = [];
|
||||
|
||||
function init() {
|
||||
|
||||
var prevalues = ($scope.model.config ? $scope.model.config.prevalues : $scope.model.prevalues) || [];
|
||||
|
||||
var items = [];
|
||||
|
||||
for (var i = 0; i < prevalues.length; i++) {
|
||||
var item = {};
|
||||
|
||||
if (Utilities.isObject(prevalues[i])) {
|
||||
item.value = prevalues[i].value;
|
||||
item.label = prevalues[i].label;
|
||||
}
|
||||
else {
|
||||
item.value = prevalues[i];
|
||||
item.label = prevalues[i];
|
||||
}
|
||||
|
||||
items.push({ value: item.value, label: item.label });
|
||||
}
|
||||
|
||||
vm.configItems = items;
|
||||
|
||||
// update view model.
|
||||
generateViewModel();
|
||||
}
|
||||
|
||||
function generateViewModel() {
|
||||
|
||||
vm.viewItems = [];
|
||||
|
||||
var iConfigItem;
|
||||
for (var i = 0; i < vm.configItems.length; i++) {
|
||||
iConfigItem = vm.configItems[i];
|
||||
vm.viewItems.push({
|
||||
value: iConfigItem.value,
|
||||
label: iConfigItem.label
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
init();
|
||||
|
||||
});
|
||||
@@ -1,6 +1,18 @@
|
||||
<div class="umb-radiobuttons-preval">
|
||||
<div class="umb-radiobuttons-preval" ng-controller="Umbraco.PrevalueEditors.RadiobuttonListController as vm">
|
||||
|
||||
<ul class="unstyled" ng-if="model.prevalues">
|
||||
{{model.value}}
|
||||
|
||||
<ul class="unstyled" ng-if="vm.viewItems.length">
|
||||
<li ng-repeat="item in vm.viewItems track by $id(item)">
|
||||
<umb-radiobutton
|
||||
value="{{item.value}}"
|
||||
model="model.value"
|
||||
text="{{item.label}}">
|
||||
</umb-radiobutton>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<!--<ul class="unstyled" ng-if="model.prevalues">
|
||||
<li ng-repeat="preval in model.prevalues">
|
||||
|
||||
<umb-radiobutton model="model.value" value="{{preval.value || preval}}">
|
||||
@@ -18,6 +30,6 @@
|
||||
</umb-radiobutton>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
</ul>-->
|
||||
|
||||
</div>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
angular.module("umbraco").controller("Umbraco.PropertyEditors.CheckboxListController",
|
||||
function ($scope, validationMessageService) {
|
||||
|
||||
var vm = this;
|
||||
const vm = this;
|
||||
|
||||
vm.configItems = [];
|
||||
vm.viewItems = [];
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<div class="umb-property-editor umb-checkboxlist" ng-controller="Umbraco.PropertyEditors.CheckboxListController as vm">
|
||||
<div class="umb-property-editor umb-checkboxlist" ng-controller="Umbraco.PropertyEditors.CheckboxListController as vm">
|
||||
|
||||
<ng-form name="checkboxListFieldForm">
|
||||
|
||||
<ul class="unstyled">
|
||||
<ul class="unstyled" ng-if="vm.viewItems.length">
|
||||
<li ng-repeat="item in vm.viewItems track by item.key">
|
||||
<umb-checkbox
|
||||
name="{{::model.alias}}_{{::vm.uniqueId}}"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
angular.module("umbraco").controller("Umbraco.PropertyEditors.RadioButtonsController",
|
||||
function ($scope, validationMessageService) {
|
||||
|
||||
var vm = this;
|
||||
const vm = this;
|
||||
|
||||
vm.viewItems = [];
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<div class="umb-property-editor umb-radiobuttons" ng-controller="Umbraco.PropertyEditors.RadioButtonsController as vm">
|
||||
<div class="umb-property-editor umb-radiobuttons" ng-controller="Umbraco.PropertyEditors.RadioButtonsController as vm">
|
||||
<ng-form name="radioButtonsFieldForm">
|
||||
|
||||
<ul class="unstyled">
|
||||
<ul class="unstyled" ng-if="vm.viewItems.length">
|
||||
<li ng-repeat="item in vm.viewItems track by item.key">
|
||||
<umb-radiobutton
|
||||
name="{{model.alias}}_{{vm.uniqueId}}"
|
||||
|
||||
Reference in New Issue
Block a user