🚸 (content): Use a draft button instead of the current system

This commit is contained in:
Kazhnuz 2025-01-23 23:12:26 +01:00
parent e8cebf6c10
commit 05f3e6fc93
2 changed files with 25 additions and 47 deletions

View file

@ -51,7 +51,7 @@ echo Bootstrap::formInputHidden(array(
<!-- TOOLBAR -->
<div class="mb-3 col-lg-6">
<button type="button" class="btn btn-light" data-bs-toggle="modal" data-bs-target="#jsmediaManagerModal"><span class="fa fa-image"></span> <?php $L->p('Images') ?></button>
<span id="jsswitchButton" data-switch="<?php echo ($page->draft() ? 'draft' : 'publish') ?>" class="ms-2 btn-outline-<?php echo ($page->draft() ? 'light' : 'success') ?> btn"><?php echo ($page->draft() ? $L->g('Draft') : $L->g('Publish')) ?></span>
<button id="jsbuttonPreview" type="button" class="btn btn-secondary"><?php $L->p('Preview') ?></button>
<?php if ($page->scheduled()) : ?>
<div class="alert alert-warning p-1 mt-1 mb-0"><?php $L->p('scheduled') ?>: <?php echo $page->date(SCHEDULED_DATE_FORMAT) ?></div>
@ -59,8 +59,8 @@ echo Bootstrap::formInputHidden(array(
</div>
<div class="col-lg-6 text-end">
<button id="jsbuttonPreview" type="button" class="btn btn-secondary"><?php $L->p('Preview') ?></button>
<button type="button" class="btn btn-primary" id="jsbuttonSave"><?php echo $L->g('Save') ?></button>
<button type="button" class="btn btn-secondary" id="jsbuttonDraft" ><?php $L->p('Draft') ?></button>
<button type="button" class="btn btn-primary" id="jsbuttonSave"><?php echo $L->g('Publish') ?></button>
</div>
</div>
@ -484,19 +484,6 @@ foreach ($customFields as $field => $options) {
};
}
// Button switch
$("#jsswitchButton").on("click", function() {
if ($(this).data("switch") == "publish") {
$(this).html('<?php $L->p('Draft') ?>');
$(this).data("switch", "draft");
$(this).attr('class', "ms-2 btn-outline-secondary btn");
} else {
$(this).html('<?php $L->p('Publish') ?>');
$(this).data("switch", "publish");
$(this).attr('class', "ms-2 btn-outline-success btn");
}
});
// Button preview
$("#jsbuttonPreview").on("click", function() {
var uuid = $("#jsuuid").val();
@ -511,13 +498,8 @@ foreach ($customFields as $field => $options) {
// Button Save
$("#jsbuttonSave").on("click", function() {
// If the switch is setted to "published", get the value from the selector
if ($("#jsswitchButton").data("switch") == "publish") {
var value = $("#jstypeSelector option:selected").val();
$("#jstype").val(value);
} else {
$("#jstype").val("draft");
}
var value = $("#jstypeSelector option:selected").val();
$("#jstype").val(value);
// Get the content
$("#jscontent").val(editorGetContent());

View file

@ -44,11 +44,11 @@ echo Bootstrap::formInputHidden(array(
<!-- TOOLBAR -->
<div class="mb-3 col-lg-6">
<button type="button" class="btn btn-light" data-bs-toggle="modal" data-bs-target="#jsmediaManagerModal"><span class="fa fa-image"></span> <?php $L->p('Images') ?></button>
<span id="jsswitchButton" data-switch="publish" class="ms-2 btn-outline-success btn"><?php $L->p('Publish') ?></span>
<button id="jsbuttonPreview" type="button" class="btn btn-secondary"><?php $L->p('Preview') ?></button>
</div>
<div class="col-lg-6 text-end">
<button id="jsbuttonPreview" type="button" class="btn btn-secondary"><?php $L->p('Preview') ?></button>
<button type="button" class="btn btn-secondary" id="jsbuttonDraft"><?php $L->p('Draft') ?></button>
<button type="button" class="btn btn-primary" id="jsbuttonSave"><?php echo $L->g('Save') ?></button>
</div>
</div>
@ -439,19 +439,6 @@ foreach ($customFields as $field => $options) {
};
}
// Button switch
$("#jsswitchButton").on("click", function() {
if ($(this).data("switch") == "publish") {
$(this).html('<?php $L->p('Draft') ?>');
$(this).data("switch", "draft");
$(this).attr('class', "ms-2 btn-outline-secondary btn");
} else {
$(this).html('<?php $L->p('Publish') ?>');
$(this).data("switch", "publish");
$(this).attr('class', "ms-2 btn-outline-success btn");
}
});
// Button preview
$("#jsbuttonPreview").on("click", function() {
var uuid = $("#jsuuid").val();
@ -467,15 +454,24 @@ foreach ($customFields as $field => $options) {
$("#jsbuttonSave").on("click", function() {
let actionParameters = '';
// If the switch is setted to "published", get the value from the selector
if ($("#jsbuttonSwitch").data("switch") == "publish") {
var value = $("#jstypeSelector option:selected").val();
$("#jstype").val(value);
actionParameters = '#' + value;
} else {
$("#jstype").val("draft");
actionParameters = '#draft';
}
var value = $("#jstypeSelector option:selected").val();
$("#jstype").val(value);
actionParameters = '#' + value;
// Get the content
$("#jscontent").val(editorGetContent());
// Submit the form
$("#jsform").attr('action', actionParameters);
$("#jsform").submit();
});
// Button Draft
$("#jsbuttonDraft").on("click", function() {
let actionParameters = '';
$("#jstype").val("draft");
actionParameters = '#draft';
// Get the content
$("#jscontent").val(editorGetContent());