wip schedule publish dialog
This commit is contained in:
@@ -536,6 +536,30 @@
|
||||
|
||||
};
|
||||
|
||||
$scope.schedule = function() {
|
||||
clearNotifications($scope.content);
|
||||
//before we launch the dialog we want to execute all client side validations first
|
||||
if (formHelper.submitForm({ scope: $scope, action: "schedule" })) {
|
||||
|
||||
var dialog = {
|
||||
parentScope: $scope,
|
||||
view: "views/content/overlays/schedule.html",
|
||||
variants: $scope.content.variants, //set a model property for the dialog
|
||||
skipFormValidation: true, //when submitting the overlay form, skip any client side validation
|
||||
submitButtonLabel: "Schedule",
|
||||
submit: function (model) {
|
||||
model.submitButtonState = "busy";
|
||||
clearNotifications($scope.content);
|
||||
model.submitButtonState = "success";
|
||||
},
|
||||
close: function () {
|
||||
overlayService.close();
|
||||
}
|
||||
};
|
||||
overlayService.open(dialog);
|
||||
}
|
||||
};
|
||||
|
||||
$scope.preview = function (content) {
|
||||
|
||||
|
||||
|
||||
@@ -75,7 +75,7 @@
|
||||
/* ---------- OVERLAY CENTER ---------- */
|
||||
.umb-overlay.umb-overlay-center {
|
||||
position: absolute;
|
||||
width: 500px;
|
||||
width: 600px;
|
||||
height: auto;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
|
||||
@@ -28,6 +28,14 @@
|
||||
|
||||
<umb-editor-footer-content-right>
|
||||
|
||||
<umb-button
|
||||
alias="schedule"
|
||||
type="button"
|
||||
button-style="info"
|
||||
action="schedule(content)"
|
||||
label="Schedule">
|
||||
</umb-button>
|
||||
|
||||
<umb-button
|
||||
ng-if="infiniteModel.infiniteMode"
|
||||
action="close()"
|
||||
|
||||
@@ -0,0 +1,139 @@
|
||||
(function () {
|
||||
"use strict";
|
||||
|
||||
function ScheduleContentController($scope, localizationService, dateHelper, userService) {
|
||||
|
||||
var vm = this;
|
||||
|
||||
vm.datePickerChange = datePickerChange;
|
||||
vm.clearPublishDate = clearPublishDate;
|
||||
vm.clearUnpublishDate = clearUnpublishDate;
|
||||
|
||||
vm.currentUser = null;
|
||||
vm.datePickerConfig = {
|
||||
pickDate: true,
|
||||
pickTime: true,
|
||||
useSeconds: false,
|
||||
format: "YYYY-MM-DD HH:mm",
|
||||
icons: {
|
||||
time: "icon-time",
|
||||
date: "icon-calendar",
|
||||
up: "icon-chevron-up",
|
||||
down: "icon-chevron-down"
|
||||
}
|
||||
};
|
||||
|
||||
function onInit() {
|
||||
|
||||
vm.variants = $scope.model.variants;
|
||||
|
||||
if(!$scope.model.title) {
|
||||
localizationService.localize("general_scheduledPublishing").then(function(value){
|
||||
$scope.model.title = value;
|
||||
});
|
||||
}
|
||||
|
||||
// get current backoffice user and format dates
|
||||
userService.getCurrentUser().then(function (currentUser) {
|
||||
|
||||
vm.currentUser = currentUser;
|
||||
|
||||
// format all dates to local
|
||||
angular.forEach(vm.variants, function(variant) {
|
||||
if(variant.releaseDate || variant.removeDate) {
|
||||
formatDatesToLocal(variant);
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
function datePickerChange(variant, event, type) {
|
||||
if (type === 'publish') {
|
||||
setPublishDate(variant, event.date.format("YYYY-MM-DD HH:mm"));
|
||||
} else if (type === 'unpublish') {
|
||||
setUnpublishDate(variant, event.date.format("YYYY-MM-DD HH:mm"));
|
||||
}
|
||||
}
|
||||
|
||||
function setPublishDate(variant, date) {
|
||||
|
||||
if (!date) {
|
||||
return;
|
||||
}
|
||||
|
||||
console.log(date);
|
||||
|
||||
//The date being passed in here is the user's local date/time that they have selected
|
||||
//we need to convert this date back to the server date on the model.
|
||||
|
||||
var serverTime = dateHelper.convertToServerStringTime(moment(date), Umbraco.Sys.ServerVariables.application.serverTimeOffset);
|
||||
|
||||
// update publish value
|
||||
variant.releaseDate = serverTime;
|
||||
|
||||
// make sure dates are formatted to the user's locale
|
||||
formatDatesToLocal(variant);
|
||||
|
||||
}
|
||||
|
||||
function setUnpublishDate(variant, date) {
|
||||
|
||||
if (!date) {
|
||||
return;
|
||||
}
|
||||
|
||||
//The date being passed in here is the user's local date/time that they have selected
|
||||
//we need to convert this date back to the server date on the model.
|
||||
|
||||
console.log(date);
|
||||
|
||||
var serverTime = dateHelper.convertToServerStringTime(moment(date), Umbraco.Sys.ServerVariables.application.serverTimeOffset);
|
||||
|
||||
// update publish value
|
||||
variant.removeDate = serverTime;
|
||||
|
||||
// make sure dates are formatted to the user's locale
|
||||
formatDatesToLocal(variant);
|
||||
|
||||
}
|
||||
|
||||
function clearPublishDate(variant) {
|
||||
if(variant && variant.releaseDate) {
|
||||
variant.releaseDate = null;
|
||||
}
|
||||
}
|
||||
|
||||
function clearUnpublishDate(variant) {
|
||||
if(variant && variant.removeDate) {
|
||||
variant.removeDate = null;
|
||||
}
|
||||
}
|
||||
|
||||
function formatDatesToLocal(variant) {
|
||||
|
||||
if(variant && variant.releaseDate) {
|
||||
variant.releaseDateFormatted = dateHelper.getLocalDate(variant.releaseDate, vm.currentUser.locale, "YYYY-MM-DD HH:mm");
|
||||
}
|
||||
|
||||
if(variant && variant.removeDate) {
|
||||
variant.removeDateFormatted = dateHelper.getLocalDate(variant.removeDate, vm.currentUser.locale, "YYYY-MM-DD HH:mm");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
onInit();
|
||||
|
||||
//when this dialog is closed, reset all 'save' flags
|
||||
$scope.$on('$destroy', function () {
|
||||
for (var i = 0; i < vm.variants.length; i++) {
|
||||
vm.variants[i].schedule = false;
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
angular.module("umbraco").controller("Umbraco.Overlays.ScheduleContentController", ScheduleContentController);
|
||||
|
||||
})();
|
||||
@@ -0,0 +1,85 @@
|
||||
<div ng-controller="Umbraco.Overlays.ScheduleContentController as vm">
|
||||
|
||||
<div style="margin-bottom: 15px;">
|
||||
<p><localize key="content_languagesToSave"></localize></p>
|
||||
</div>
|
||||
|
||||
<div class="umb-list umb-list--condensed">
|
||||
|
||||
<div class="umb-list-item" ng-repeat="variant in vm.variants">
|
||||
<ng-form name="scheduleSelectorForm">
|
||||
<div class="flex">
|
||||
<input
|
||||
id="{{variant.language.culture}}"
|
||||
name="saveVariantSelector"
|
||||
type="checkbox"
|
||||
ng-model="variant.schedule"
|
||||
ng-change="vm.changeSelection(variant)"
|
||||
style="margin-right: 8px;" />
|
||||
<div>
|
||||
|
||||
<label for="{{variant.language.culture}}" style="margin-bottom: 2px;">
|
||||
<span>{{ variant.language.name }}</span>
|
||||
<strong ng-if="variant.language.isMandatory" class="umb-control-required">*</strong>
|
||||
</label>
|
||||
|
||||
<div>
|
||||
<umb-variant-state class="umb-permission__description" variant="variant"></umb-variant-state>
|
||||
</div>
|
||||
|
||||
<div ng-if="variant.schedule" class="flex items-center" style="margin-top: 10px; margin-bottom: 10px;">
|
||||
<div style="font-size: 13px; margin-right: 5px;">Publish: </div>
|
||||
|
||||
<div class="btn-group flex" style="font-size: 14px; margin-right: 10px;">
|
||||
<umb-date-time-picker
|
||||
options="vm.datePickerConfig"
|
||||
on-change="vm.datePickerChange(variant, event, 'publish')">
|
||||
|
||||
<div ng-if="variant.releaseDate" class="btn umb-button--xxs">
|
||||
{{variant.releaseDateFormatted}}
|
||||
</div>
|
||||
|
||||
<a ng-hide="variant.releaseDate" href="" class="bold" style="color: #00aea2; text-decoration: underline;">
|
||||
<localize key="content_setDate">Set date</localize>
|
||||
</a>
|
||||
|
||||
</umb-date-time-picker>
|
||||
|
||||
<a ng-if="variant.releaseDate" ng-click="vm.clearPublishDate(variant)" class="btn umb-button--xxs dropdown-toggle umb-button-group__toggle">
|
||||
<span class="icon icon-wrong"></span>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div style="font-size: 13px; margin-right: 5px;">Unpublish:</div>
|
||||
|
||||
<div class="btn-group flex" style="font-size: 14px;">
|
||||
<umb-date-time-picker
|
||||
options="vm.datePickerConfig"
|
||||
on-change="vm.datePickerChange(variant, event, 'unpublish')">
|
||||
|
||||
<div ng-if="variant.removeDate" class="btn umb-button--xxs">
|
||||
{{variant.removeDateFormatted}}
|
||||
</div>
|
||||
|
||||
<a ng-hide="variant.removeDate" href="" class="bold" style="color: #00aea2; text-decoration: underline;">
|
||||
<localize key="content_setDate">Set date</localize>
|
||||
</a>
|
||||
|
||||
</umb-date-time-picker>
|
||||
|
||||
<a ng-if="variant.removeDate" ng-click="vm.clearUnpublishDate(variant)" class="btn umb-button--xxs dropdown-toggle umb-button-group__toggle">
|
||||
<span class="icon icon-wrong"></span>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</ng-form>
|
||||
</div>
|
||||
<br/>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
Reference in New Issue
Block a user