Use umb-checkbox in template section (#6531)
This commit is contained in:
committed by
Sebastiaan Janssen
parent
bfdbc4cb8b
commit
f018b32f99
@@ -5,8 +5,8 @@
|
||||
|
||||
var vm = this;
|
||||
|
||||
vm.field;
|
||||
vm.defaultValue;
|
||||
vm.field = null;
|
||||
vm.defaultValue = null;
|
||||
vm.recursive = false;
|
||||
vm.showDefaultValue = false;
|
||||
|
||||
@@ -16,10 +16,14 @@
|
||||
|
||||
function onInit() {
|
||||
|
||||
var labelKeys = [
|
||||
"template_insertPageField"
|
||||
];
|
||||
|
||||
// set default title
|
||||
if(!$scope.model.title) {
|
||||
localizationService.localize("template_insertPageField").then(function(value){
|
||||
$scope.model.title = value;
|
||||
localizationService.localizeMany(labelKeys).then(function (data) {
|
||||
$scope.model.title = data[0];
|
||||
});
|
||||
}
|
||||
|
||||
@@ -37,42 +41,40 @@
|
||||
|
||||
function generateOutputSample() {
|
||||
|
||||
var fallback;
|
||||
var fallback = null;
|
||||
|
||||
if(vm.recursive !== false && vm.defaultValue !== undefined){
|
||||
if (vm.recursive !== false && vm.defaultValue !== null) {
|
||||
fallback = "Fallback.To(Fallback.Ancestors, Fallback.DefaultValue)";
|
||||
}else if(vm.recursive !== false){
|
||||
} else if (vm.recursive !== false) {
|
||||
fallback = "Fallback.ToAncestors";
|
||||
}else if(vm.defaultValue !== undefined){
|
||||
} else if (vm.defaultValue !== null) {
|
||||
fallback = "Fallback.ToDefaultValue";
|
||||
}
|
||||
|
||||
var pageField = (vm.field !== undefined ? '@Model.Value("' + vm.field + '"' : "")
|
||||
+ (fallback !== undefined? ', fallback: ' + fallback : "")
|
||||
+ (vm.defaultValue !== undefined ? ', defaultValue: new HtmlString("' + vm.defaultValue + '")' : "")
|
||||
var pageField = (vm.field !== null ? '@Model.Value("' + vm.field + '"' : "")
|
||||
+ (fallback !== null? ', fallback: ' + fallback : "")
|
||||
+ (vm.defaultValue !== null ? ', defaultValue: new HtmlString("' + vm.defaultValue + '")' : "")
|
||||
|
||||
+ (vm.field ? ')' : "");
|
||||
|
||||
$scope.model.umbracoField = pageField;
|
||||
|
||||
return pageField;
|
||||
|
||||
}
|
||||
|
||||
function submit(model) {
|
||||
if($scope.model.submit) {
|
||||
if ($scope.model.submit) {
|
||||
$scope.model.submit(model);
|
||||
}
|
||||
}
|
||||
|
||||
function close() {
|
||||
if($scope.model.close) {
|
||||
if ($scope.model.close) {
|
||||
$scope.model.close();
|
||||
}
|
||||
}
|
||||
|
||||
onInit();
|
||||
|
||||
}
|
||||
|
||||
angular.module("umbraco").controller("Umbraco.Editors.InsertFieldController", InsertFieldController);
|
||||
|
||||
@@ -33,10 +33,9 @@
|
||||
|
||||
<!-- Default value -->
|
||||
<div>
|
||||
<div style="margin-bottom: 20px;">
|
||||
<i class="icon icon-add blue" ng-hide="vm.showDefaultValue"></i>
|
||||
<a href="" ng-click="vm.showDefaultValue=true" ng-hide="vm.showDefaultValue"><localize key="templateEditor_addDefaultValue">Add default value</localize></a>
|
||||
</div>
|
||||
<button type="button" class="umb-node-preview-add mb3" ng-click="vm.showDefaultValue=true" ng-hide="vm.showDefaultValue">
|
||||
<localize key="templateEditor_addDefaultValue">Add default value</localize>
|
||||
</button>
|
||||
|
||||
<div class="control-group umb-control-group -no-border" ng-hide="!vm.showDefaultValue">
|
||||
<div class="umb-el-wrap">
|
||||
@@ -52,13 +51,17 @@
|
||||
<div class="control-group umb-control-group">
|
||||
<div class="umb-el-wrap">
|
||||
<div class="controls">
|
||||
<label class="control-label" >
|
||||
<label class="control-label">
|
||||
<localize key="templateEditor_recursive">Recursive</localize>
|
||||
</label>
|
||||
<label for="recursive">
|
||||
<input id="recursive" type="checkbox" name="recursive" ng-model="vm.recursive">
|
||||
<localize key="templateEditor_recursiveDescr">Yes, make it recursive</localize>
|
||||
</label>
|
||||
<div class="flex">
|
||||
<umb-checkbox name="recursive"
|
||||
disabled="!vm.field"
|
||||
model="vm.recursive"
|
||||
text="Yes, make it recursive"
|
||||
label-key="templateEditor_recursiveDescr">
|
||||
</umb-checkbox>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,26 +1,42 @@
|
||||
(function () {
|
||||
"use strict";
|
||||
|
||||
function TemplateSectionsController($scope, formHelper) {
|
||||
function TemplateSectionsController($scope, formHelper, localizationService) {
|
||||
|
||||
var vm = this;
|
||||
|
||||
vm.labels = {};
|
||||
|
||||
vm.select = select;
|
||||
vm.submit = submit;
|
||||
vm.close = close;
|
||||
|
||||
$scope.model.mandatoryRenderSection = false;
|
||||
|
||||
if(!$scope.model.title) {
|
||||
$scope.model.title = "Sections";
|
||||
}
|
||||
|
||||
function onInit() {
|
||||
if($scope.model.hasMaster) {
|
||||
if ($scope.model.hasMaster) {
|
||||
$scope.model.insertType = 'addSection';
|
||||
} else {
|
||||
$scope.model.insertType = 'renderBody';
|
||||
}
|
||||
|
||||
var labelKeys = [
|
||||
"template_insertSections",
|
||||
"template_sectionMandatory"
|
||||
];
|
||||
|
||||
localizationService.localizeMany(labelKeys).then(function (data) {
|
||||
vm.labels.title = data[0];
|
||||
vm.labels.sectionMandatory = data[1];
|
||||
|
||||
setTitle(vm.labels.title);
|
||||
});
|
||||
}
|
||||
|
||||
function setTitle(value) {
|
||||
if (!$scope.model.title) {
|
||||
$scope.model.title = value;
|
||||
}
|
||||
}
|
||||
|
||||
function select(type) {
|
||||
@@ -34,13 +50,12 @@
|
||||
}
|
||||
|
||||
function close() {
|
||||
if($scope.model.close) {
|
||||
if ($scope.model.close) {
|
||||
$scope.model.close();
|
||||
}
|
||||
}
|
||||
|
||||
onInit();
|
||||
|
||||
}
|
||||
|
||||
angular.module("umbraco").controller("Umbraco.Editors.TemplateSectionsController", TemplateSectionsController);
|
||||
|
||||
@@ -44,10 +44,10 @@
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label>
|
||||
<input type="checkbox" ng-model="model.mandatoryRenderSection" /> <localize key="template_sectionMandatory" />
|
||||
</label>
|
||||
|
||||
<div class="flex">
|
||||
<umb-checkbox model="model.mandatoryRenderSection" text="{{vm.labels.sectionMandatory}}" />
|
||||
</div>
|
||||
|
||||
<div class="umb-insert-code-box__description">
|
||||
<localize key="template_sectionMandatoryDesc" />
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user