Merge remote-tracking branch 'origin/develop' into wip/laravel-6

This commit is contained in:
Ben Thomson 2020-02-26 17:40:47 +08:00
commit 0394494fbe
12 changed files with 62 additions and 40 deletions

View File

@ -212,7 +212,7 @@ class ListController extends ControllerBehavior
*/ */
if ($searchWidget = $toolbarWidget->getSearchWidget()) { if ($searchWidget = $toolbarWidget->getSearchWidget()) {
$searchWidget->bindEvent('search.submit', function () use ($widget, $searchWidget) { $searchWidget->bindEvent('search.submit', function () use ($widget, $searchWidget) {
$widget->setSearchTerm($searchWidget->getActiveTerm()); $widget->setSearchTerm($searchWidget->getActiveTerm(), true);
return $widget->onRefresh(); return $widget->onRefresh();
}); });

View File

@ -139,7 +139,7 @@
right: auto; right: auto;
} }
.field-markdowneditor.is-fullscreen { .field-markdowneditor.is-fullscreen {
z-index: 300; z-index: 600;
position: fixed !important; position: fixed !important;
top: 0; top: 0;
left: 0; left: 0;

View File

@ -89,7 +89,7 @@ return [
'updates_link' => 'Mettre à jour', 'updates_link' => 'Mettre à jour',
'warnings_pending' => 'Certaines anomalies méritent votre attention', 'warnings_pending' => 'Certaines anomalies méritent votre attention',
'warnings_nil' => 'Aucun avertissement à afficher', 'warnings_nil' => 'Aucun avertissement à afficher',
'warnings_link' => 'Vue', 'warnings_link' => 'Voir',
'core_build' => 'Version du système', 'core_build' => 'Version du système',
'event_log' => 'Journal des évènements', 'event_log' => 'Journal des évènements',
'request_log' => 'Journal des requêtes', 'request_log' => 'Journal des requêtes',

View File

@ -506,14 +506,14 @@ class Form extends WidgetBase
* *
* Event::listen('backend.form.extendFieldsBefore', function ((\Backend\Widgets\Form) $formWidget) { * Event::listen('backend.form.extendFieldsBefore', function ((\Backend\Widgets\Form) $formWidget) {
* // You should always check to see if you're extending correct model/controller * // You should always check to see if you're extending correct model/controller
* if (!$widget->model instanceof \Foo\Example\Models\Bar) { * if (!$formWidget->model instanceof \Foo\Example\Models\Bar) {
* return; * return;
* } * }
* *
* // Here you can't use addFields() because it will throw you an exception because form is not yet created * // Here you can't use addFields() because it will throw you an exception because form is not yet created
* // and it does not have tabs and fields * // and it does not have tabs and fields
* // For this example we will pretend that we want to add a new field named example_field * // For this example we will pretend that we want to add a new field named example_field
* $widget->fields['example_field'] = [ * $formWidget->fields['example_field'] = [
* 'label' => 'Example field', * 'label' => 'Example field',
* 'comment' => 'Your example field', * 'comment' => 'Your example field',
* 'type' => 'text', * 'type' => 'text',
@ -524,14 +524,14 @@ class Form extends WidgetBase
* *
* $formWidget->bindEvent('form.extendFieldsBefore', function () use ((\Backend\Widgets\Form $formWidget)) { * $formWidget->bindEvent('form.extendFieldsBefore', function () use ((\Backend\Widgets\Form $formWidget)) {
* // You should always check to see if you're extending correct model/controller * // You should always check to see if you're extending correct model/controller
* if (!$widget->model instanceof \Foo\Example\Models\Bar) { * if (!$formWidget->model instanceof \Foo\Example\Models\Bar) {
* return; * return;
* } * }
* *
* // Here you can't use addFields() because it will throw you an exception because form is not yet created * // Here you can't use addFields() because it will throw you an exception because form is not yet created
* // and it does not have tabs and fields * // and it does not have tabs and fields
* // For this example we will pretend that we want to add a new field named example_field * // For this example we will pretend that we want to add a new field named example_field
* $widget->fields['example_field'] = [ * $formWidget->fields['example_field'] = [
* 'label' => 'Example field', * 'label' => 'Example field',
* 'comment' => 'Your example field', * 'comment' => 'Your example field',
* 'type' => 'text', * 'type' => 'text',
@ -579,17 +579,17 @@ class Form extends WidgetBase
* *
* Event::listen('backend.form.extendFields', function ((\Backend\Widgets\Form) $formWidget) { * Event::listen('backend.form.extendFields', function ((\Backend\Widgets\Form) $formWidget) {
* // Only for the User controller * // Only for the User controller
* if (!$widget->getController() instanceof \RainLab\User\Controllers\Users) { * if (!$formWidget->getController() instanceof \RainLab\User\Controllers\Users) {
* return; * return;
* } * }
* *
* // Only for the User model * // Only for the User model
* if (!$widget->model instanceof \RainLab\User\Models\User) { * if (!$formWidget->model instanceof \RainLab\User\Models\User) {
* return; * return;
* } * }
* *
* // Add an extra birthday field * // Add an extra birthday field
* $widget->addFields([ * $formWidget->addFields([
* 'birthday' => [ * 'birthday' => [
* 'label' => 'Birthday', * 'label' => 'Birthday',
* 'comment' => 'Select the users birthday', * 'comment' => 'Select the users birthday',
@ -598,24 +598,24 @@ class Form extends WidgetBase
* ]); * ]);
* *
* // Remove a Surname field * // Remove a Surname field
* $widget->removeField('surname'); * $formWidget->removeField('surname');
* }); * });
* *
* Or * Or
* *
* $formWidget->bindEvent('form.extendFields', function () use ((\Backend\Widgets\Form $formWidget)) { * $formWidget->bindEvent('form.extendFields', function () use ((\Backend\Widgets\Form $formWidget)) {
* // Only for the User controller * // Only for the User controller
* if (!$widget->getController() instanceof \RainLab\User\Controllers\Users) { * if (!$formWidget->getController() instanceof \RainLab\User\Controllers\Users) {
* return; * return;
* } * }
* *
* // Only for the User model * // Only for the User model
* if (!$widget->model instanceof \RainLab\User\Models\User) { * if (!$formWidget->model instanceof \RainLab\User\Models\User) {
* return; * return;
* } * }
* *
* // Add an extra birthday field * // Add an extra birthday field
* $widget->addFields([ * $formWidget->addFields([
* 'birthday' => [ * 'birthday' => [
* 'label' => 'Birthday', * 'label' => 'Birthday',
* 'comment' => 'Select the users birthday', * 'comment' => 'Select the users birthday',
@ -624,7 +624,7 @@ class Form extends WidgetBase
* ]); * ]);
* *
* // Remove a Surname field * // Remove a Surname field
* $widget->removeField('surname'); * $formWidget->removeField('surname');
* }); * });
* *
*/ */
@ -1294,6 +1294,9 @@ class Form extends WidgetBase
if (!is_array($fieldOptions) && !$fieldOptions) { if (!is_array($fieldOptions) && !$fieldOptions) {
try { try {
list($model, $attribute) = $field->resolveModelAttribute($this->model, $field->fieldName); list($model, $attribute) = $field->resolveModelAttribute($this->model, $field->fieldName);
if (!$model) {
throw new Exception();
}
} }
catch (Exception $ex) { catch (Exception $ex) {
throw new ApplicationException(Lang::get('backend::lang.field.options_method_invalid_model', [ throw new ApplicationException(Lang::get('backend::lang.field.options_method_invalid_model', [

View File

@ -210,7 +210,9 @@ class Lists extends WidgetBase
/* /*
* Configure the list widget * Configure the list widget
*/ */
$this->recordsPerPage = $this->getUserPreference('per_page', $this->recordsPerPage); if ($this->showSetup) {
$this->recordsPerPage = $this->getUserPreference('per_page', $this->recordsPerPage);
}
if ($this->showPagination == 'auto') { if ($this->showPagination == 'auto') {
$this->showPagination = $this->recordsPerPage && $this->recordsPerPage > 0; $this->showPagination = $this->recordsPerPage && $this->recordsPerPage > 0;
@ -640,9 +642,7 @@ class Lists extends WidgetBase
protected function getCurrentPageNumber($query) protected function getCurrentPageNumber($query)
{ {
$currentPageNumber = $this->currentPageNumber; $currentPageNumber = $this->currentPageNumber;
if (empty($currentPageNumber)) {
if (!$currentPageNumber && empty($this->searchTerm)) {
// Restore the last visited page from the session if available.
$currentPageNumber = $this->getSession('lastVisitedPage'); $currentPageNumber = $this->getSession('lastVisitedPage');
} }
@ -728,7 +728,7 @@ class Lists extends WidgetBase
/* /*
* Supplied column list * Supplied column list
*/ */
if ($this->columnOverride === null) { if ($this->showSetup && $this->columnOverride === null) {
$this->columnOverride = $this->getUserPreference('visible', null); $this->columnOverride = $this->getUserPreference('visible', null);
} }
@ -1408,13 +1408,18 @@ class Lists extends WidgetBase
* Applies a search term to the list results, searching will disable tree * Applies a search term to the list results, searching will disable tree
* view if a value is supplied. * view if a value is supplied.
* @param string $term * @param string $term
* @param boolean $resetPagination
*/ */
public function setSearchTerm($term) public function setSearchTerm($term, $resetPagination = false)
{ {
if (!empty($term)) { if (!empty($term)) {
$this->showTree = false; $this->showTree = false;
} }
if ($resetPagination) {
$this->currentPageNumber = 1;
}
$this->searchTerm = $term; $this->searchTerm = $term;
} }

View File

@ -166,7 +166,10 @@
* Render tab form fields once a lazy tab is selected. * Render tab form fields once a lazy tab is selected.
*/ */
FormWidget.prototype.bindLazyTabs = function() { FormWidget.prototype.bindLazyTabs = function() {
this.$el.on('click', '.tab-lazy [data-toggle="tab"]', function() { var tabControl = $('[data-control=tab]', this.$el),
tabContainer = $('.nav-tabs', tabControl)
tabContainer.on('click', '.tab-lazy [data-toggle="tab"]', function() {
var $el = $(this), var $el = $(this),
handlerName = $el.data('tab-lazy-handler') handlerName = $el.data('tab-lazy-handler')
@ -191,6 +194,11 @@
} }
}) })
}) })
// If initial active tab is lazy loaded, load it immediately
if ($('> li.active.tab-lazy', tabContainer).length) {
$('> li.active.tab-lazy > [data-toggle="tab"]', tabContainer).trigger('click')
}
} }
/* /*

View File

@ -1,6 +1,6 @@
<!-- Number --> <!-- Number -->
<?php if ($this->previewMode): ?> <?php if ($this->previewMode): ?>
<span class="form-control"><?= $field->value ? e($field->value) : '&nbsp;' ?></span> <span class="form-control"><?= isset($field->value) ? e($field->value) : '&nbsp;' ?></span>
<?php else: ?> <?php else: ?>
<?php <?php
$min = isset($field->config['min']) ? $field->config['min'] : false; $min = isset($field->config['min']) ? $field->config['min'] : false;

View File

@ -34,7 +34,8 @@
name="page" name="page"
class="form-control input-sm custom-select select-no-search" class="form-control input-sm custom-select select-no-search"
data-request="<?= $this->getEventHandler('onPaginate') ?>" data-request="<?= $this->getEventHandler('onPaginate') ?>"
data-load-indicator="<?= e(trans('backend::lang.list.loading')) ?>"> data-load-indicator="<?= e(trans('backend::lang.list.loading')) ?>"
autocomplete="off">
<?php for($i = 1; $i <= $pageLast ; $i++): ?> <?php for($i = 1; $i <= $pageLast ; $i++): ?>
<option value="<?= $i ?>" <?= $i === $pageCurrent ? 'selected' : '' ?>><?= $i ?></option> <option value="<?= $i ?>" <?= $i === $pageCurrent ? 'selected' : '' ?>><?= $i ?></option>
<?php endfor ?> <?php endfor ?>

View File

@ -29,7 +29,8 @@
<select <select
disabled disabled
name="page" name="page"
class="form-control input-sm custom-select select-no-search"> class="form-control input-sm custom-select select-no-search"
autocomplete="off">
<option value="<?= $pageCurrent ?>" selected><?= $pageCurrent ?></option> <option value="<?= $pageCurrent ?>" selected><?= $pageCurrent ?></option>
</select> </select>
<?php if ($hasMorePages): ?> <?php if ($hasMorePages): ?>

View File

@ -11,7 +11,7 @@ return [
'error_deleting' => "Error deleting the template file ':name'. Please check write permissions.", 'error_deleting' => "Error deleting the template file ':name'. Please check write permissions.",
'delete_success' => 'Templates deleted: :count.', 'delete_success' => 'Templates deleted: :count.',
'file_name_required' => 'The File Name field is required.', 'file_name_required' => 'The File Name field is required.',
'safe_mode_enabled' => 'Safe mode is currently enabled. Editing the PHP code of CMS templates is disabled.' 'safe_mode_enabled' => 'Safe mode is currently enabled. Editing the PHP code of CMS templates is disabled. To disable safe mode, set the `cms.enableSafeMode` configuration value to `false`.',
], ],
'dashboard' => [ 'dashboard' => [
'active_theme' => [ 'active_theme' => [

View File

@ -13,20 +13,25 @@
*/ */
$(document).render(function(){ $(document).render(function(){
var formatSelectOption = function(state) { var formatSelectOption = function(state) {
if (!state.id) var text = $('<span>').text(state.text).html()
return state.text; // optgroup
if (!state.id) {
return text // optgroup
}
var $option = $(state.element), var $option = $(state.element),
iconClass = state.icon ? state.icon : $option.data('icon'), iconClass = state.icon ? state.icon : $option.data('icon'),
imageSrc = state.image ? state.image : $option.data('image') imageSrc = state.image ? state.image : $option.data('image')
if (iconClass) if (iconClass) {
return '<i class="select-icon '+iconClass+'"></i> ' + state.text return '<i class="select-icon '+iconClass+'"></i> ' + text
}
if (imageSrc) if (imageSrc) {
return '<img class="select-image" src="'+imageSrc+'" alt="" /> ' + state.text return '<img class="select-image" src="'+imageSrc+'" alt="" /> ' + text
}
return state.text return text
} }
var selectOptions = { var selectOptions = {

View File

@ -3496,13 +3496,12 @@ if(!isReset){var numberinputs=$('.field-number input','#controlFilterPopoverNum'
numberinputs.each(function(index,numberinput){var number=$(numberinput).val() numberinputs.each(function(index,numberinput){var number=$(numberinput).val()
numbers.push(number)})} numbers.push(number)})}
this.updateScopeNumberSetting(this.$activeScope,numbers);this.scopeValues[this.activeScopeName]={numbers:numbers} this.updateScopeNumberSetting(this.$activeScope,numbers);this.scopeValues[this.activeScopeName]={numbers:numbers}
this.isActiveScopeDirty=true;this.$activeScope.data('oc.popover').hide()}}(window.jQuery);(function($){$(document).render(function(){var formatSelectOption=function(state){if(!state.id) this.isActiveScopeDirty=true;this.$activeScope.data('oc.popover').hide()}}(window.jQuery);(function($){$(document).render(function(){var formatSelectOption=function(state){var text=$('<span>').text(state.text).html()
return state.text;var $option=$(state.element),iconClass=state.icon?state.icon:$option.data('icon'),imageSrc=state.image?state.image:$option.data('image') if(!state.id){return text}
if(iconClass) var $option=$(state.element),iconClass=state.icon?state.icon:$option.data('icon'),imageSrc=state.image?state.image:$option.data('image')
return'<i class="select-icon '+iconClass+'"></i> '+state.text if(iconClass){return'<i class="select-icon '+iconClass+'"></i> '+text}
if(imageSrc) if(imageSrc){return'<img class="select-image" src="'+imageSrc+'" alt="" /> '+text}
return'<img class="select-image" src="'+imageSrc+'" alt="" /> '+state.text return text}
return state.text}
var selectOptions={templateResult:formatSelectOption,templateSelection:formatSelectOption,escapeMarkup:function(m){return m},width:'style'} var selectOptions={templateResult:formatSelectOption,templateSelection:formatSelectOption,escapeMarkup:function(m){return m},width:'style'}
$('select.custom-select').each(function(){var $element=$(this),extraOptions={dropdownCssClass:'',containerCssClass:''} $('select.custom-select').each(function(){var $element=$(this),extraOptions={dropdownCssClass:'',containerCssClass:''}
if($element.data('select2')!=null){return true;} if($element.data('select2')!=null){return true;}