Introduce content app helper (#9425)

This commit is contained in:
Matt Brailsford
2020-11-27 13:02:19 +00:00
committed by GitHub
parent 8d96c6e842
commit a6f5e48f43
3 changed files with 39 additions and 4 deletions

View File

@@ -2,7 +2,7 @@
'use strict';
function ContentEditController($rootScope, $scope, $routeParams, $q, $window,
appState, contentResource, entityResource, navigationService, notificationsService,
appState, contentResource, entityResource, navigationService, notificationsService, contentAppHelper,
serverValidationManager, contentEditingHelper, localizationService, formHelper, umbRequestHelper,
editorState, $http, eventsService, overlayService, $location, localStorageService, treeService,
$exceptionHandler) {
@@ -282,7 +282,7 @@
$scope.page.saveButtonStyle = content.trashed || content.isElement || isBlueprint ? "primary" : "info";
// only create the save/publish/preview buttons if the
// content app is "Conent"
if ($scope.activeApp && $scope.activeApp.alias !== "umbContent" && $scope.activeApp.alias !== "umbInfo" && $scope.activeApp.alias !== "umbListView") {
if ($scope.activeApp && !contentAppHelper.isContentBasedApp($scope.activeApp)) {
$scope.defaultButton = null;
$scope.subButtons = null;
$scope.page.showSaveButton = false;

View File

@@ -24,7 +24,7 @@
controller: umbVariantContentController
};
function umbVariantContentController($scope) {
function umbVariantContentController($scope, contentAppHelper) {
var unsubscribe = [];
@@ -110,7 +110,7 @@
function onAppChanged(activeApp) {
// disable the name field if the active content app is not "Content" or "Info"
vm.nameDisabled = (activeApp && activeApp.alias !== "umbContent" && activeApp.alias !== "umbInfo" && activeApp.alias !== "umbListView");
vm.nameDisabled = (activeApp && !contentAppHelper.isContentBasedApp(activeApp));
}
/**

View File

@@ -0,0 +1,35 @@
/**
* @ngdoc service
* @name umbraco.services.contentAppHelper
* @description A helper service for content app related functions.
**/
function contentAppHelper() {
var service = {};
/**
* Default known content based apps.
*/
service.CONTENT_BASED_APPS = [ "umbContent", "umbInfo", "umbListView" ];
/**
* @ngdoc method
* @name umbraco.services.contentAppHelper#isContentBasedApp
* @methodOf umbraco.services.contentAppHelper
*
* @param {object} app A content app to check
*
* @description
* Determines whether the supplied content app is a known content based app
*
*/
service.isContentBasedApp = function (app) {
return service.CONTENT_BASED_APPS.indexOf(app.alias) !== -1;
}
return service;
}
angular.module('umbraco.services').factory('contentAppHelper', contentAppHelper);