Update button title on creating of not published content (#6318)

* Update button title on creating of not published content

* Update wording on creating of scheduled content

---------

Co-authored-by: Lucas Bartholemy <luke-@users.noreply.github.com>
This commit is contained in:
Yuriy Bakhtin 2023-05-11 19:27:23 +04:00 committed by GitHub
parent 6d6a0cd4ac
commit 77b7879bf2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 23 additions and 8 deletions

View File

@ -30,4 +30,5 @@ HumHub Changelog
- Enh #6298: Move the "Write a new comment" field style to a generic field that can be used by other modules
- Enh #6310: Module information is localized with `docs/uk/README.md` or `README.uk.md`.
- Enh #6311: Added {cols, rows} to textarea() control.
- Enh #6304: Update button title on creating of not published content
- Enh #6319: Duplicate File Converter Logs

View File

@ -108,7 +108,7 @@ class ScheduleOptionsForm extends Model
public function getStateTitle(): string
{
return Yii::t('ContentModule.base', 'Scheduled at {dateTime}', [
return Yii::t('ContentModule.base', 'Scheduled for {dateTime}', [
'dateTime' => Yii::$app->formatter->asDatetime($this->date, 'short')
]);
}

View File

@ -187,9 +187,10 @@ humhub.module('content.form', function(module, require, $) {
}
};
CreateForm.prototype.changeState = function(state, title) {
CreateForm.prototype.changeState = function(state, title, buttonTitle) {
const stateInput = this.$.find('input[name=state]');
let stateLabel = this.$.find('.label-content-state');
const button = this.$.find('#post_submit_button');
if (!stateLabel.length) {
stateLabel = $('<span>').addClass('label label-warning label-content-state');
@ -197,10 +198,14 @@ humhub.module('content.form', function(module, require, $) {
}
if (stateInput.data('initial') === undefined) {
stateInput.data('initial', stateInput.val());
stateInput.data('initial', {
state: stateInput.val(),
buttonTitle: button.html()
});
}
if (typeof(state) === 'object') {
buttonTitle = state.$target.data('button-title');
title = state.$target.data('state-title');
state = state.$target.data('state');
if (stateInput.val() == state) {
@ -210,12 +215,16 @@ humhub.module('content.form', function(module, require, $) {
stateInput.val(state);
stateLabel.show().html(title);
button.html(buttonTitle);
}
CreateForm.prototype.resetState = function() {
const stateInput = this.$.find('input[name=state]');
if (stateInput.data('initial') !== undefined) {
stateInput.val(stateInput.data('initial'));
const button = this.$.find('#post_submit_button');
const initial = stateInput.data('initial');
if (initial !== undefined) {
stateInput.val(initial.state);
button.html(initial.buttonTitle);
}
this.$.find('input[name^=scheduled]').remove();
this.$.find('.label-content-state').hide();
@ -241,7 +250,10 @@ humhub.module('content.form', function(module, require, $) {
}
if (modalGlobal.find('#scheduleoptionsform-enabled').is(':checked')) {
that.changeState(modalGlobal.find('input[name=state]').val(), modalGlobal.find('input[name=stateTitle]').val());
that.changeState(
modalGlobal.find('input[name=state]').val(),
modalGlobal.find('input[name=stateTitle]').val(),
modalGlobal.find('input[name=buttonTitle]').val());
that.setScheduleOption('scheduledDate', modalGlobal.find('input[name=scheduledDate]').val());
} else {
that.resetState();

View File

@ -22,6 +22,7 @@ use humhub\widgets\ModalDialog;
<?php $form = ActiveForm::begin() ?>
<?= Html::hiddenInput('state', Content::STATE_SCHEDULED) ?>
<?= Html::hiddenInput('stateTitle', $scheduleOptions->getStateTitle()) ?>
<?= Html::hiddenInput('buttonTitle', Yii::t('ContentModule.base', 'Save scheduling')) ?>
<?= Html::hiddenInput('scheduledDate', $scheduleOptions->date) ?>
<div class="modal-body">
@ -56,4 +57,4 @@ use humhub\widgets\ModalDialog;
$('#scheduleoptionsform-enabled').click(function () {
$(this).closest('form').find('input[type=text]').prop('disabled', !$(this).is(':checked'));
});
</script>
</script>

View File

@ -103,7 +103,8 @@ use yii\helpers\Html;
->icon('edit')
->options([
'data-state' => Content::STATE_DRAFT,
'data-state-title' => Yii::t('ContentModule.base', 'Draft')
'data-state-title' => Yii::t('ContentModule.base', 'Draft'),
'data-button-title' => Yii::t('ContentModule.base', 'Save as draft')
]) ?>
</li>
<li>