Skip to content

Commit

Permalink
Ajustes no componente spam-warning Ref.: #1
Browse files Browse the repository at this point in the history
  • Loading branch information
israelmelo committed Sep 5, 2024
1 parent 3bb3ffa commit e07de80
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 7 deletions.
17 changes: 14 additions & 3 deletions assets/css/admin-spam-warning.css
Original file line number Diff line number Diff line change
@@ -1,11 +1,22 @@
.spam-warning {
.spam-alert {
position: relative;
top: 20px;
text-align: center;
z-index: 1000;
padding: 10px;
}

.spam-warning input[type="checkbox"] {
margin-left: 10px;
.spam-alert .spam-click {
background: none;
color: white;
border: none;
padding: 0;
font: inherit;
cursor: pointer;
text-decoration: underline;
font-weight: bold;
}

.spam-alert .warning .spam-click {
color: black;
}
7 changes: 7 additions & 0 deletions components/spam-warning/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,15 @@ app.component('spam-warning', {

methods: {
setSpamStatus() {
this.spamStatus = !this.spamStatus;
this.entity.spam_status = this.spamStatus;
this.entity.save();
}
},

mounted() {
if (this.entity.spam_status === null) {
this.entity.spam_status = false;
}
}
});
38 changes: 34 additions & 4 deletions components/spam-warning/template.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,47 @@
* @var MapasCulturais\Themes\BaseV2\Theme $this
*/
use MapasCulturais\i;
use SpamDetector\Plugin;

$instance = Plugin::getInstance();
$entity = $this->controller->requestedEntity;
$dict_entity = $instance->dictEntity($entity, 'pronome');
$dict_entity = ucfirst($dict_entity);

$this->import('
mc-alert
mc-confirm-button
');
?>

<div class="spam-warning">
<mc-alert type="warning" class="spam-warning">
<div class="spam-alert">
<mc-alert v-if="!entity.spam_status" type="danger" class="spam-alert">
<label>
<?= i::__('Um termo de spam foi detectado.') ?>
<input type="checkbox" v-model="spamStatus" @change="setSpamStatus"/><?= i::__('Classificar como Spam') ?>
<?= i::__('Identificamos um possível spam neste cadastro. CASO NÃO SEJA,') ?>

<mc-confirm-button message="<?= i::esc_attr__('Deseja retirar do spam?')?>" @confirm="setSpamStatus()">
<template #button="modal">
<button @click="modal.open()" class="spam-click">
<?php i::_e("clique aqui") ?>
</button>
</template>
</mc-confirm-button>

<?= i::__('para desativar mensagens futuras. CASO SEJA SPAM, clique no botão <strong>Excluir</strong> no rodapé.') ?>
</label>
</mc-alert>

<mc-alert v-else type="warning" class="spam-alert">
<label>
<?= i::__("{$dict_entity} já foi detectada como possível spam. Caso deseje reativar as notificações,") ?>

<mc-confirm-button message="<?= i::esc_attr__('Deseja marcar como spam?')?>" @confirm="setSpamStatus()">
<template #button="modal">
<button @click="modal.open()" class="spam-click">
<?= i::__('clique aqui') ?>
</button>
</template>
</mc-confirm-button>
</label>
</mc-alert>
</div>

0 comments on commit e07de80

Please sign in to comment.