Skip to content

Commit

Permalink
Feature/modelos (#427)
Browse files Browse the repository at this point in the history
* feat: add action para entidade

* feat: add template do componente modal salvar modelo

* feat: add regra front gerar modelo

* feat: add redme como usar o componente

* feat: aplica regra apenas para entidade oportunidade

* feat: add requisição componente success

* feat: add trait generate model

* feat: add geração de modelo com especificação se é modelo

* feat: define identificação se é modelo e se é oficial

* feat: define padrão é modelo

* feat: adiciona filtro retornar oportunidades diferente de modelos

* feat: aplica regra no componente apenas para entidade oportunidade

* feat: redireciona para meus modelos

* feat: se modelo habilita ação de somente remover

* feat: muda regra status quando modelo e gera fields e files para os forms

* feat: add testes de validação da geração e sucesso do modelo
  • Loading branch information
vicmagpac authored and lpirola committed Sep 4, 2024
1 parent 81e0334 commit 2d46f64
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 13 deletions.
7 changes: 4 additions & 3 deletions src/conf/opportunity-types.php
Original file line number Diff line number Diff line change
Expand Up @@ -248,12 +248,13 @@ function compareNamesOpportunity ($item1, $item2) {
'isModel' => array(
'type' => 'integer',
'label' => \MapasCulturais\i::__('É modelo?'),
'default_value' => 0,
'default_value' => 0
),
'modelType' => array(
'isModelOfficial' => array(
'type' => 'integer',
'label' => \MapasCulturais\i::__('Tipo de modelo'),
'label' => \MapasCulturais\i::__('É modelo oficial?'),
),

),
'items' => $items,

Expand Down
2 changes: 1 addition & 1 deletion src/core/Traits/EntityGenerateModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ private function generateMetadata() : void
}

$this->opportunityModel->setMetadata('isModel', 1);
$this->opportunityModel->setMetadata('modelType', 1);
$this->opportunityModel->setMetadata('isModelOfficial', 0);

$this->opportunityModel->saveTerms();
}
Expand Down
7 changes: 4 additions & 3 deletions src/modules/Entities/components/entity-actions/template.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,10 @@
<p><?php i::_e('Deseja continuar?') ?></p>
</template>
</mc-confirm-button>

<opportunity-create-model :entity="entity" classes="col-12"></opportunity-create-model>

<div v-if="entity.currentUserPermissions?.modify && entity.status != -2 && entity.__objectType == 'opportunity'">
<opportunity-create-model :entity="entity" classes="col-12"></opportunity-create-model>
</div>

<?php $this->applyTemplateHook('entity-actions--primary', 'end') ?>
</div>
<?php $this->applyTemplateHook('entity-actions--leftGroupBtn', 'after'); ?>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,13 @@ app.component('opportunity-create-model', {

methods: {
async save() {
this.__processing = this.text('Gerando modelo...');

const api = new API(this.entity.__objectType);

let objt = this.formData;
objt.entityId = this.entity.id;


let error = null;

if (error = this.validade(objt)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
?>
<div class="col-12">
<mc-modal title="<?= i::__('Salvar modelo') ?>">
<template v-if="!sendSuccess" #default>
<template #default>
<p>Para salvar um modelo, preencha os campos abaixo.</p><br>
<div>
<div class="field">
Expand All @@ -31,9 +31,6 @@
<button class="button button--primary" @click="save(modal)"><?= i::__('Salvar modelo') ?></button>
<button class="button button--text button--text-del" @click="modal.close()"><?= i::__('cancelar') ?></button>
</template>
<template v-if="sendSuccess" #actions="modal">
<button class="button button--primary" @click="modal.close()"><?= i::__('Fechar') ?></button>
</template>

<template #button="modal">
<button type="button" @click="modal.open();" class="button button--icon button--sm"><?= i::__('Salvar modelo') ?></button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@
return [
'Recaptcha inválida' => i::__('Recaptcha inválida'),
'Todos os campos são obrigatorio' => i::__('Todos os campos são obrigatorio'),
'Modelo salvo com sucesso' => i::__('Modelo salvo com sucesso'),
'Modelo gerado com sucesso' => i::__('Modelo gerado com sucesso'),
'Gerando modelo...' => i::__('Gerando modelo...'),
];

0 comments on commit 2d46f64

Please sign in to comment.