Merge remote-tracking branch 'origin/v12/dev' into v13/dev
This commit is contained in:
@@ -14,12 +14,12 @@ public class SliderConfiguration
|
||||
[ConfigurationField("initVal2", "Initial value 2", "number", Description = "Used when range is enabled")]
|
||||
public decimal InitialValue2 { get; set; }
|
||||
|
||||
[ConfigurationField("minVal", "Minimum value", "number")]
|
||||
[ConfigurationField("minVal", "Minimum value", "number", Description = "Must be smaller than the Maximum value")]
|
||||
public decimal MinimumValue { get; set; }
|
||||
|
||||
[ConfigurationField("maxVal", "Maximum value", "number")]
|
||||
[ConfigurationField("maxVal", "Maximum value", "number", Description = "Must be larger than the Minimum value")]
|
||||
public decimal MaximumValue { get; set; }
|
||||
|
||||
[ConfigurationField("step", "Step increments", "number")]
|
||||
[ConfigurationField("step", "Step increments", "number", Description = "Must be a positive value")]
|
||||
public decimal StepIncrements { get; set; }
|
||||
}
|
||||
|
||||
@@ -25,4 +25,19 @@ public class SliderConfigurationEditor : ConfigurationEditor<SliderConfiguration
|
||||
ioHelper, editorConfigurationParser)
|
||||
{
|
||||
}
|
||||
|
||||
public override Dictionary<string, object> ToConfigurationEditor(SliderConfiguration? configuration)
|
||||
{
|
||||
// negative step increments can be configured in the back-office. they will cause the slider to
|
||||
// crash the entire back-office. as we can't configure min and max values for the number prevalue
|
||||
// editor, we have to this instead to limit the damage.
|
||||
// logically, the step increments should be inverted instead of hardcoding them to 1, but the
|
||||
// latter might point people in the direction of their misconfiguration.
|
||||
if (configuration?.StepIncrements <= 0)
|
||||
{
|
||||
configuration.StepIncrements = 1;
|
||||
}
|
||||
|
||||
return base.ToConfigurationEditor(configuration);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright (c) Umbraco.
|
||||
// Copyright (c) Umbraco.
|
||||
// See LICENSE for more details.
|
||||
|
||||
using System.Text;
|
||||
@@ -92,6 +92,6 @@ namespace Umbraco.Cms.Core.PropertyEditors
|
||||
|
||||
[Obsolete("Use the overload that specifies availableCultures, scheduled for removal in v14")]
|
||||
public IEnumerable<KeyValuePair<string, IEnumerable<object?>>> GetIndexValues(IProperty property, string? culture, string? segment, bool published)
|
||||
=> GetIndexValues(property, culture, segment, published);
|
||||
=> GetIndexValues(property, culture, segment, published, Enumerable.Empty<string>());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -328,6 +328,6 @@ public class RichTextPropertyEditor : DataEditor
|
||||
|
||||
[Obsolete("Use the overload with the 'availableCultures' parameter instead, scheduled for removal in v14")]
|
||||
public IEnumerable<KeyValuePair<string, IEnumerable<object?>>> GetIndexValues(IProperty property, string? culture, string? segment, bool published)
|
||||
=> GetIndexValues(property, culture, segment, published);
|
||||
=> GetIndexValues(property, culture, segment, published, Enumerable.Empty<string>());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -148,6 +148,17 @@ angular.module("umbraco.directives")
|
||||
*/
|
||||
function _upload(file) {
|
||||
|
||||
if (!file) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (file.$error) {
|
||||
file.done = true;
|
||||
scope.processed.push(file);
|
||||
file.messages.push({type: "Error", header: "Error"});
|
||||
return;
|
||||
}
|
||||
|
||||
scope.propertyAlias = scope.propertyAlias ? scope.propertyAlias : "umbracoFile";
|
||||
scope.contentTypeAlias = scope.contentTypeAlias ? scope.contentTypeAlias : "umbracoAutoSelect";
|
||||
|
||||
|
||||
@@ -7,8 +7,10 @@
|
||||
* @param {any} fileManager
|
||||
* @param {any} mediaHelper
|
||||
* @param {any} angularHelper
|
||||
* @param {any} $attrs
|
||||
* @param {any} notificationsService
|
||||
*/
|
||||
function umbPropertyFileUploadController($scope, $q, fileManager, mediaHelper, angularHelper, $attrs) {
|
||||
function umbPropertyFileUploadController($scope, $q, fileManager, mediaHelper, angularHelper, $attrs, notificationsService) {
|
||||
|
||||
//NOTE: this component supports multiple files, though currently the uploader does not but perhaps sometime in the future
|
||||
// we'd want it to, so i'll leave the multiple file support in place
|
||||
@@ -271,15 +273,25 @@
|
||||
|
||||
if (args.files && args.files.length > 0) {
|
||||
|
||||
const filesAllowed = [];
|
||||
|
||||
for (let i = 0; i < args.files.length; i++) {
|
||||
if (fileManager.maxFileSize && args.files[i].size > fileManager.maxFileSize) {
|
||||
notificationsService.error(`File upload "${args.files[i].name}"`, `File size of ${args.files[i].size / 1000} KB exceeds the maximum allowed size of ${fileManager.maxFileSize / 1000} KB`);
|
||||
} else {
|
||||
filesAllowed.push(args.files[i]);
|
||||
}
|
||||
}
|
||||
|
||||
//set the files collection
|
||||
fileManager.setFiles({
|
||||
propertyAlias: vm.propertyAlias,
|
||||
files: args.files,
|
||||
files: filesAllowed,
|
||||
culture: vm.culture,
|
||||
segment: vm.segment
|
||||
});
|
||||
|
||||
updateModelFromSelectedFiles(args.files).then(function(newVal) {
|
||||
updateModelFromSelectedFiles(filesAllowed).then(function(newVal) {
|
||||
angularHelper.safeApply($scope,
|
||||
function() {
|
||||
//pass in the file names and the model files
|
||||
|
||||
@@ -14,6 +14,17 @@ function fileManager($rootScope) {
|
||||
|
||||
|
||||
var mgr = {
|
||||
/**
|
||||
* @ngdoc property
|
||||
* @name umbraco.services.fileManager#maxFileSize
|
||||
* @propertyOf umbraco.services.fileManager
|
||||
* @type {Number}
|
||||
* @default 0
|
||||
* @description
|
||||
* The max file size allowed to be uploaded to the server in bytes
|
||||
*/
|
||||
maxFileSize: parseInt(Umbraco.Sys.ServerVariables.umbracoSettings.maxFileSize ?? '0', 10) * 1000,
|
||||
|
||||
/**
|
||||
* @ngdoc function
|
||||
* @name umbraco.services.fileManager#setFiles
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
* @doc https://www.tiny.cloud/docs/tinymce/6/
|
||||
*/
|
||||
function tinyMceService($rootScope, $q, imageHelper, $locale, $http, $timeout, stylesheetResource, macroResource, macroService,
|
||||
$routeParams, umbRequestHelper, angularHelper, userService, editorService, entityResource, eventsService, localStorageService, mediaHelper) {
|
||||
$routeParams, umbRequestHelper, angularHelper, userService, editorService, entityResource, eventsService, localStorageService, mediaHelper, fileManager) {
|
||||
|
||||
//These are absolutely required in order for the macros to render inline
|
||||
//we put these as extended elements because they get merged on top of the normal allowed elements by tiny mce
|
||||
@@ -202,6 +202,17 @@ function tinyMceService($rootScope, $q, imageHelper, $locale, $http, $timeout, s
|
||||
|
||||
function uploadImageHandler(blobInfo, progress) {
|
||||
return new Promise(function (resolve, reject) {
|
||||
const blob = blobInfo.blob();
|
||||
|
||||
// if the file size is greater than the max file size, reject it
|
||||
if (fileManager.maxFileSize > 0 && blob.size > fileManager.maxFileSize) {
|
||||
reject({
|
||||
message: `The file size (${blob.size / 1000} KB) exceeded the maximum allowed size of ${fileManager.maxFileSize / 1000} KB.`,
|
||||
remove: true
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
const xhr = new XMLHttpRequest();
|
||||
xhr.open('POST', Umbraco.Sys.ServerVariables.umbracoUrls.tinyMceApiBaseUrl + 'UploadImage');
|
||||
|
||||
@@ -222,12 +233,18 @@ function tinyMceService($rootScope, $q, imageHelper, $locale, $http, $timeout, s
|
||||
};
|
||||
|
||||
xhr.onerror = function () {
|
||||
reject('Image upload failed due to a XHR Transport error. Code: ' + xhr.status);
|
||||
reject({
|
||||
message: 'Image upload failed due to a XHR Transport error. Code: ' + xhr.status,
|
||||
remove: true
|
||||
});
|
||||
};
|
||||
|
||||
xhr.onload = function () {
|
||||
if (xhr.status < 200 || xhr.status >= 300) {
|
||||
reject('HTTP Error: ' + xhr.status);
|
||||
reject({
|
||||
message: 'HTTP Error: ' + xhr.status,
|
||||
remove: true
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -237,7 +254,10 @@ function tinyMceService($rootScope, $q, imageHelper, $locale, $http, $timeout, s
|
||||
data = data.split("\n");
|
||||
|
||||
if (!data.length > 1) {
|
||||
reject('Unrecognized text string: ' + data);
|
||||
reject({
|
||||
message: 'Unrecognized text string: ' + data,
|
||||
remove: true
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -246,12 +266,18 @@ function tinyMceService($rootScope, $q, imageHelper, $locale, $http, $timeout, s
|
||||
try {
|
||||
json = JSON.parse(data[1]);
|
||||
} catch (e) {
|
||||
reject('Invalid JSON: ' + data + ' - ' + e.message);
|
||||
reject({
|
||||
message: 'Invalid JSON: ' + data + ' - ' + e.message,
|
||||
remove: true
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
if (!json || typeof json.tmpLocation !== 'string') {
|
||||
reject('Invalid JSON: ' + data);
|
||||
reject({
|
||||
message: 'Invalid JSON: ' + data,
|
||||
remove: true
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -265,7 +291,7 @@ function tinyMceService($rootScope, $q, imageHelper, $locale, $http, $timeout, s
|
||||
};
|
||||
|
||||
const formData = new FormData();
|
||||
formData.append('file', blobInfo.blob(), blobInfo.blob().name);
|
||||
formData.append('file', blob, blob.name);
|
||||
|
||||
xhr.send(formData);
|
||||
});
|
||||
|
||||
@@ -56,7 +56,7 @@
|
||||
<div>
|
||||
<span>{{ file.name }}</span>
|
||||
<span ng-if="file.messages.length > 0 || file.$error" class="file-messages">
|
||||
<span class="errorMessage color-red" ng-repeat="message in file.messages">{{message.header}}: {{message.message}}</span>
|
||||
<span class="errorMessage color-red" ng-repeat="message in ::file.messages" ng-if="message.message">{{::message.header}}: {{::message.message}}</span>
|
||||
<span ng-if="file.$error === 'pattern'" class="errorMessage color-red"><localize key="media_disallowedFileType"></localize></span>
|
||||
<span ng-if="file.$error === 'maxSize'" class="errorMessage color-red"><localize key="media_maxFileSize"></localize> "{{maxFileSize}}"</span>
|
||||
</span>
|
||||
|
||||
Reference in New Issue
Block a user