Compare commits

..

6 Commits

3 changed files with 53 additions and 14 deletions

View File

@ -67,10 +67,19 @@ add_action('edit_form_after_title', function () {
$status_mdp = get_field('mdp_status', get_the_ID());
$post_status = get_post_status();
$translatedStatus = translate_wordpress_online_statuses($post_status);
$post_link = get_preview_post_link();
if ($screen && $screen->post_type === 'artisans') {
?>
<h1 class="admin-artisan-title"><?php echo get_the_title() ?></h1>
<?php if (!empty($post_link) && $screen->action !== 'add') : ?>
<div class="preview-artisan-link">
<a href="<?php echo $post_link; ?>" target="_blank" class="button button-primary">
<span class="dashicons dashicons-admin-users" style="margin-right: 5px;"></span>
Voir la fiche
</a>
</div>
<?php endif; ?>
<div id="top-status" class="top-status">
<div class="state-container">
<p>État :</p>
@ -90,7 +99,7 @@ add_action('edit_form_after_title', function () {
<!-- <button id="set-offline-status" class="button button-secondary">Mettre Hors Ligne</button>
<button id="set-online-status" class="button button-secondary">Mettre En Ligne</button> -->
<div id="save-post-custom">
<button class=" button button-primary">Sauvegarder</button>
<button class="">Sauvegarder</button>
<span class="spinner"></span>
</div>
@ -110,12 +119,24 @@ add_action('edit_form_after_title', function () {
// Déclencher la sauvegarde
$('#publish').trigger('click');
// Réactiver le bouton et restaurer le texte après un délai
// setTimeout(function() {
// $button.prop('disabled', false).text('Sauvegarder');
// $spinner.hide();
// $spinner.removeClass('is-active');
// }, 10000);
// Vérifier les erreurs ACF après un court délai
setTimeout(function() {
// Vérifier s'il y a des messages d'erreur ACF
if ($('.acf-notice.-error').length > 0) {
// Réinitialiser le bouton immédiatement si une erreur est détectée
$button.prop('disabled', false).text('Sauvegarder');
$spinner.hide();
$spinner.removeClass('is-active');
}
}, 2000);
// Réactiver le bouton et restaurer le texte après un délai plus long
// (ceci ne s'exécutera que si la page n'est pas rechargée)
setTimeout(function() {
$button.prop('disabled', false).text('Sauvegarder');
$spinner.hide();
$spinner.removeClass('is-active');
}, 20000);
});
});
</script>
@ -167,7 +188,7 @@ function render_custom_chantier_box_content($post)
$return_to = get_edit_post_link($artisan_id);
echo '<h3> Chantiers réalisé par l\'entreprise </h3>';
echo '<h3> Chantiers réalisés </h3>';
echo '<ul>';
while ($chantiers->have_posts()) {
$chantiers->the_post();

View File

@ -28,7 +28,7 @@ function metiers_patrimoine_create_posttype()
'menu_icon' => 'data:image/svg+xml;base64,' . base64_encode('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 512" fill="currentColor"><!--!Font Awesome Free 6.5.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2024 Fonticons, Inc.--><path d="M72 88a56 56 0 1 1 112 0A56 56 0 1 1 72 88zM64 245.7C54 256.9 48 271.8 48 288s6 31.1 16 42.3V245.7zm144.4-49.3C178.7 222.7 160 261.2 160 304c0 34.3 12 65.8 32 90.5V416c0 17.7-14.3 32-32 32H96c-17.7 0-32-14.3-32-32V389.2C26.2 371.2 0 332.7 0 288c0-61.9 50.1-112 112-112h32c24 0 46.2 7.5 64.4 20.3zM448 416V394.5c20-24.7 32-56.2 32-90.5c0-42.8-18.7-81.3-48.4-107.7C449.8 183.5 472 176 496 176h32c61.9 0 112 50.1 112 112c0 44.7-26.2 83.2-64 101.2V416c0 17.7-14.3 32-32 32H480c-17.7 0-32-14.3-32-32zm8-328a56 56 0 1 1 112 0A56 56 0 1 1 456 88zM576 245.7v84.7c10-11.3 16-26.1 16-42.3s-6-31.1-16-42.3zM320 32a64 64 0 1 1 0 128 64 64 0 1 1 0-128zM240 304c0 16.2 6 31 16 42.3V261.7c-10 11.3-16 26.1-16 42.3zm144-42.3v84.7c10-11.3 16-26.1 16-42.3s-6-31.1-16-42.3zM448 304c0 44.7-26.2 83.2-64 101.2V448c0 17.7-14.3 32-32 32H288c-17.7 0-32-14.3-32-32V405.2c-37.8-18-64-56.5-64-101.2c0-61.9 50.1-112 112-112h32c61.9 0 112 50.1 112 112z"/></svg>'),
// 'menu_icon' => 'dashicons-hammer',
'menu_position' => 5.1,
'supports' => array('title', 'custom-fields', 'thumbnail', 'revisions'),
'supports' => array('title', 'custom-fields', 'thumbnail', 'revisions', 'preview'),
)
);
// **** CHANTIERS

View File

@ -359,7 +359,11 @@ body.post-type-artisans {
#admin_artisan_chantier_list {
@apply border border-solid border-neutral-300;
h3 {
@apply font-medium;
/* @apply font-medium; */
color: #3c434a;
font-weight: 500;
font-size: 13px !important;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen-Sans, Ubuntu, Cantarell, 'Helvetica Neue', sans-serif;
}
background: rgba(0, 0, 0, 0);
@ -369,7 +373,7 @@ body.post-type-artisans {
}
ul a {
@apply text-patrimoine-sante-securite text-lg flex items-center gap-2;
@apply text-patrimoine-sante-securite text-base flex items-center gap-2;
filter: brightness(80%);
img {
@apply w-6 h-6 object-contain filter-patrimoine-sante-securite;
@ -652,14 +656,17 @@ select[data-enpassusermodified='yes'] {
}
}
#acf-group_67581cdaf3262 {
@apply border-2 border-patrimoine-sante-securite border-solid p-0 rounded-xl;
@apply border border-patrimoine-sante-securite border-solid rounded-t-xl p-0;
@apply bg-white;
/* border: 2px solid red !important; */
.acf-field-6758467534c1e {
@apply px-[10px];
label {
@apply font-normal !text-white text-xl bg-patrimoine-sante-securite px-4 py-2 rounded-t-xl block;
@apply !text-xs;
@apply font-normal !text-white bg-patrimoine-sante-securite rounded-t-xl px-4 py-2 block;
/* font-family: 13px !important; */
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen-Sans, Ubuntu, Cantarell, 'Helvetica Neue', sans-serif;
}
}
.acf-field:not(.acf-field-6758467534c1e) {
@ -674,7 +681,10 @@ select[data-enpassusermodified='yes'] {
#save-post-custom {
@apply ml-auto w-fit p-0 mr-0;
button {
@apply rounded-xl bg-amber-600 border-none text-white px-4 !py-1 mr-0;
@apply rounded-xl bg-amber-600 border-none text-white !px-4 !py-3 mr-0;
}
button:disabled {
@apply bg-neutral-300;
}
.spinner:not(.is-active) {
@apply !hidden;
@ -702,6 +712,14 @@ select[data-enpassusermodified='yes'] {
}
}
.preview-artisan-link {
@apply !mb-12;
a {
@apply !bg-patrimoine-sante-securite !flex !items-center gap-2 w-fit !mt-4;
@apply bg-red-400 text-white !border-none !rounded-xl px-4 !py-1 ml-auto;
}
}
/* -----------------------------------------------------------
Admin styles
-----------------------------------------------------------*/