U4-7748 Models Builder - needs to be in control of the models-out-of-date status
This commit is contained in:
@@ -1,26 +0,0 @@
|
||||
function modelsResource($q, $http, umbRequestHelper) {
|
||||
|
||||
// TODO - should use BackOfficeController to register urls? How can we extend it?
|
||||
// TODO - this shouldn't exist in core!!
|
||||
|
||||
return {
|
||||
getModelsOutOfDateStatus: function() {
|
||||
return umbRequestHelper.resourcePromise(
|
||||
$http.get(
|
||||
/*umbRequestHelper.getApiUrl(
|
||||
"modelsApiBaseUrl",
|
||||
"GetModelsOutOfDateStatus")*/ "/Umbraco/BackOffice/ModelsBuilder/ModelsBuilder/GetModelsOutOfDateStatus"),
|
||||
"Failed to get models out-of-date status");
|
||||
},
|
||||
|
||||
buildModels: function() {
|
||||
return umbRequestHelper.resourcePromise(
|
||||
$http.get(
|
||||
/*umbRequestHelper.getApiUrl(
|
||||
"modelsApiBaseUrl",
|
||||
"BuildModels")*/ "/Umbraco/BackOffice/ModelsBuilder/ModelsBuilder/BuildModels"),
|
||||
"Failed to build models");
|
||||
}
|
||||
};
|
||||
}
|
||||
angular.module("umbraco.resources").factory("modelsResource", modelsResource);
|
||||
@@ -9,7 +9,7 @@
|
||||
(function () {
|
||||
"use strict";
|
||||
|
||||
function DocumentTypesEditController($scope, $routeParams, modelsResource, contentTypeResource, dataTypeResource, editorState, contentEditingHelper, formHelper, navigationService, iconHelper, contentTypeHelper, notificationsService, $filter, $q, localizationService, overlayHelper) {
|
||||
function DocumentTypesEditController($scope, $routeParams, $injector, contentTypeResource, dataTypeResource, editorState, contentEditingHelper, formHelper, navigationService, iconHelper, contentTypeHelper, notificationsService, $filter, $q, localizationService, overlayHelper) {
|
||||
|
||||
var vm = this;
|
||||
var localizeSaving = localizationService.localize("general_saving");
|
||||
@@ -46,48 +46,58 @@
|
||||
}
|
||||
];
|
||||
|
||||
var modelsResource = $injector.has("modelsBuilderResource") ? $injector.get("modelsBuilderResource") : null;
|
||||
var modelsBuilderEnabled = Umbraco.Sys.ServerVariables.umbracoPlugins.modelsBuilder.enabled;
|
||||
|
||||
//disable by default, turn on if detected correctly.
|
||||
vm.page.modelsBuilder = false;
|
||||
modelsResource.getModelsOutOfDateStatus().then(function () {
|
||||
vm.page.modelsBuilder = true;
|
||||
});
|
||||
vm.page.modelsBuilder = false;
|
||||
if (modelsBuilderEnabled && modelsResource) {
|
||||
modelsResource.getModelsOutOfDateStatus().then(function (result) {
|
||||
|
||||
//Models builder mode:
|
||||
if (result.status === 100) {
|
||||
return;
|
||||
}
|
||||
|
||||
vm.page.defaultButton = {
|
||||
hotKey: "ctrl+s",
|
||||
labelKey: "buttons_save",
|
||||
letter: "S",
|
||||
type: "submit",
|
||||
handler: function () { vm.save(); }
|
||||
};
|
||||
vm.page.subButtons = [{
|
||||
hotKey: "ctrl+g",
|
||||
labelKey: "buttons_generateModels",
|
||||
letter: "G",
|
||||
handler: function(){
|
||||
vm.page.modelsBuilder = true;
|
||||
|
||||
vm.page.saveButtonState = "busy";
|
||||
notificationsService.info("Building models", "this can take abit of time, don't worry");
|
||||
//Models builder mode:
|
||||
|
||||
modelsResource.buildModels().then(function () {
|
||||
vm.page.saveButtonState = "init";
|
||||
vm.page.defaultButton = {
|
||||
hotKey: "ctrl+s",
|
||||
labelKey: "buttons_save",
|
||||
letter: "S",
|
||||
type: "submit",
|
||||
handler: function () { vm.save(); }
|
||||
};
|
||||
vm.page.subButtons = [{
|
||||
hotKey: "ctrl+g",
|
||||
labelKey: "buttons_generateModels",
|
||||
letter: "G",
|
||||
handler: function () {
|
||||
|
||||
//clear and add success
|
||||
notificationsService.success("Models Generated");
|
||||
vm.page.saveButtonState = "busy";
|
||||
notificationsService.info("Building models", "this can take abit of time, don't worry");
|
||||
|
||||
//just calling this to get the servar back to life
|
||||
modelsResource.getModelsOutOfDateStatus();
|
||||
if (modelsBuilderEnabled && modelsResource) {
|
||||
modelsResource.buildModels().then(function () {
|
||||
vm.page.saveButtonState = "init";
|
||||
|
||||
}, function () {
|
||||
notificationsService.error("Models could not be generated");
|
||||
vm.page.saveButtonState = "error";
|
||||
});
|
||||
}
|
||||
}];
|
||||
//clear and add success
|
||||
notificationsService.success("Models Generated");
|
||||
|
||||
//just calling this to get the servar back to life
|
||||
modelsResource.getModelsOutOfDateStatus();
|
||||
|
||||
}, function () {
|
||||
notificationsService.error("Models could not be generated");
|
||||
vm.page.saveButtonState = "error";
|
||||
});
|
||||
}
|
||||
}
|
||||
}];
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
vm.page.keyboardShortcutsOverview = [
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user