Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX - dropdown de Tipos de espaço agora aparecem em ordem alfabética #304

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,214 changes: 677 additions & 537 deletions src/core/App.php

Large diffs are not rendered by default.

535 changes: 295 additions & 240 deletions src/core/Entity.php

Large diffs are not rendered by default.

372 changes: 200 additions & 172 deletions src/core/Theme.php

Large diffs are not rendered by default.

758 changes: 393 additions & 365 deletions src/modules/Components/assets/js/components-base/API.js

Large diffs are not rendered by default.

1,587 changes: 826 additions & 761 deletions src/modules/Components/assets/js/components-base/Entity.js

Large diffs are not rendered by default.

191 changes: 97 additions & 94 deletions src/modules/Entities/components/create-space/script.js
Original file line number Diff line number Diff line change
@@ -1,102 +1,105 @@
app.component('create-space', {
template: $TEMPLATES['create-space'],
emits: ['create'],
app.component("create-space", {
template: $TEMPLATES["create-space"],
emits: ["create"],

setup() {
// os textos estão localizados no arquivo texts.php deste componente
const text = Utils.getTexts('create-space')
return { text }
},
setup() {
// os textos estão localizados no arquivo texts.php deste componente
const text = Utils.getTexts("create-space");
return { text };
},

created() {
this.iterationFields();
var stat = 'publish';
},
created() {
this.iterationFields();
var stat = "publish";
},

data() {
return {
entity: null,
fields: [],
}
},
data() {
return {
entity: null,
fields: [],
};
},

props: {
editable: {
type: Boolean,
default: true
},
},
props: {
editable: {
type: Boolean,
default: true,
},
},

computed: {
areaErrors() {
return this.entity.__validationErrors['term-area'];
},
areaClasses() {
return this.areaErrors ? 'field error' : 'field';
},
modalTitle() {
if (this.entity?.id) {
if (this.entity.status == 1) {
return __('espaçoCriado', 'create-space');
} else {
return __('criarRascunho', 'create-space');
}
} else {
return __('criarEspaço', 'create-space');
computed: {
areaErrors() {
return this.entity.__validationErrors["term-area"];
},
areaClasses() {
return this.areaErrors ? "field error" : "field";
},
modalTitle() {
if (this.entity?.id) {
if (this.entity.status == 1) {
return __("espaçoCriado", "create-space");
} else {
return __("criarRascunho", "create-space");
}
} else {
return __("criarEspaço", "create-space");
}
},
},

}
},
},
methods: {
iterationFields() {
let skip = [
"createTimestamp",
"id",
"location",
"name",
"shortDescription",
"status",
"type",
"_type",
"userId",
];
Object.keys($DESCRIPTIONS.space).forEach((item) => {
if (
!skip.includes(item) &&
$DESCRIPTIONS.space[item].required
) {
this.fields.push(item);
}
});
},
createEntity() {
this.entity = Vue.ref(new Entity("space"));
this.entity.type = 1;
this.entity.terms = { area: [] };
},
createDraft(modal) {
this.entity.status = 0;
this.save(modal);
},
createPublic(modal) {
//lançar dois eventos
this.entity.status = 1;
this.save(modal);
},
save(modal) {
modal.loading(true);
this.entity
.save()
.then((response) => {
this.$emit("create", response);
modal.loading(false);
Utils.pushEntityToList(this.entity);
})
.catch((e) => {
modal.loading(false);
});
},

methods: {
iterationFields() {
let skip = [
'createTimestamp',
'id',
'location',
'name',
'shortDescription',
'status',
'type',
'_type',
'userId',
];
Object.keys($DESCRIPTIONS.space).forEach((item) => {
if (!skip.includes(item) && $DESCRIPTIONS.space[item].required) {
this.fields.push(item);
}
})
},
createEntity() {
this.entity = Vue.ref(new Entity('space'));
this.entity.type = 1;
this.entity.terms = { area: [] }

},
createDraft(modal) {
this.entity.status = 0;
this.save(modal);
},
createPublic(modal) {
//lançar dois eventos
this.entity.status = 1;
this.save(modal);
},
save(modal) {
modal.loading(true);
this.entity.save().then((response) => {
this.$emit('create', response)
modal.loading(false);
Utils.pushEntityToList(this.entity);

}).catch((e) => {
modal.loading(false);
});
},

destroyEntity() {
// para o conteúdo da modal não sumir antes dela fechar
setTimeout(() => this.entity = null, 200);
}
},
destroyEntity() {
// para o conteúdo da modal não sumir antes dela fechar
setTimeout(() => (this.entity = null), 200);
},
},
});
47 changes: 24 additions & 23 deletions src/modules/Entities/components/create-space/template.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php
<?php

/**
* @var MapasCulturais\App $app
* @var MapasCulturais\Themes\BaseV2\Theme $this
Expand All @@ -11,43 +12,43 @@
entity-terms
mc-link
mc-modal
');
');
?>
<mc-modal :title="modalTitle" classes="create-modal create-space-modal" button-label="<?php i::_e('Criar Espaço')?>" @open="createEntity()" @close="destroyEntity()">
<mc-modal :title="modalTitle" classes="create-modal create-space-modal" button-label="<?php i::_e('Criar Espaço') ?>" @open="createEntity()" @close="destroyEntity()">
<template v-if="entity && !entity.id" #default>
<label><?php i::_e('Crie um espaço com informações básicas')?><br><?php i::_e('e de forma rápida')?></label>
<label><?php i::_e('Crie um espaço com informações básicas e de forma rápida') ?></label>
<div class="create-modal__fields">
<entity-field :entity="entity" hide-required label=<?php i::esc_attr_e("Nome ou título")?> prop="name"></entity-field>
<entity-field :entity="entity" hide-required :editable="true" label="<?php i::esc_attr_e("Selecione o tipo do espaço")?>" prop="type"></entity-field>
<entity-field :entity="entity" hide-required label=<?php i::esc_attr_e("Nome ou título") ?> prop="name"></entity-field>
<entity-field :entity="entity" hide-required :editable="true" label="<?php i::esc_attr_e("Selecione o tipo do espaço") ?>" prop="type"></entity-field>
<entity-terms :entity="entity" hide-required :editable="true" :classes="areaClasses" taxonomy='area' title="<?php i::esc_attr_e("Área de Atuação") ?>"></entity-terms>
<entity-field :entity="entity" hide-required prop="shortDescription" label="<?php i::esc_attr_e("Adicione uma Descrição curta para o Espaço")?>"></entity-field>
<entity-field :entity="entity" hide-required prop="shortDescription" label="<?php i::esc_attr_e("Adicione uma Descrição curta para o Espaço") ?>"></entity-field>
{{entity.id}}
</div>
</template>

<template v-if="entity?.id" #default>
<label><?php i::_e('Você pode completar as informações do seu espaço agora ou pode deixar para depois. ');?></label><br><br>
<label><?php i::_e('Para completar e publicar seu novo espaço, acesse a área <b>Rascunhos</b> em <b>Meus Espaços</b> no <b>Painel de Controle</b>. ');?></label>
<label><?php i::_e('Você pode completar as informações do seu espaço agora ou pode deixar para depois. '); ?></label><br><br>
<label><?php i::_e('Para completar e publicar seu novo espaço, acesse a área <b>Rascunhos</b> em <b>Meus Espaços</b> no <b>Painel de Controle</b>. '); ?></label>

</template>

<template #button="modal">
<slot :modal="modal"></slot>
</template>

<template v-if="!entity?.id" #actions="modal">
<button class="button button--primary" @click="createPublic(modal)"><?php i::_e('Criar e Publicar')?></button>
<button class="button button--solid-dark" @click="createDraft(modal)"><?php i::_e('Criar em Rascunho')?></button>
<button class="button button--text button--text-del " @click="modal.close()"><?php i::_e('Cancelar')?></button>
<button class="button button--primary" @click="createPublic(modal)"><?php i::_e('Criar e Publicar') ?></button>
<button class="button button--solid-dark" @click="createDraft(modal)"><?php i::_e('Criar em Rascunho') ?></button>
<button class="button button--text button--text-del " @click="modal.close()"><?php i::_e('Cancelar') ?></button>
</template>
<template v-if="entity?.id && entity.status==1" #actions="modal">
<mc-link :entity="entity" class="button button--primary-outline button--icon"><?php i::_e('Ver Espaço');?></mc-link>
<button class="button button--secondarylight button--icon " @click="modal.close()"><?php i::_e('Completar Depois')?></button>
<mc-link :entity="entity" route='edit' class="button button--primary button--icon"><?php i::_e('Completar Informações')?></mc-link>
</template>
<template v-if="entity?.id && entity.status==0" #actions="modal">
<mc-link :entity="entity" class="button button--primary-outline button--icon"><?php i::_e('Ver Espaço');?></mc-link>
<button class="button button--secondarylight button--icon " @click="modal.close()"><?php i::_e('Completar Depois')?></button>
<mc-link :entity="entity" route='edit' class="button button--primary button--icon"><?php i::_e('Completar Informações')?></mc-link>
<mc-link :entity="entity" class="button button--primary-outline button--icon"><?php i::_e('Ver Espaço'); ?></mc-link>
<button class="button button--secondarylight button--icon " @click="modal.close()"><?php i::_e('Completar Depois') ?></button>
<mc-link :entity="entity" route='edit' class="button button--primary button--icon"><?php i::_e('Completar Informações') ?></mc-link>
</template>
<template v-if="entity?.id && entity.status==0" #actions="modal">
<mc-link :entity="entity" class="button button--primary-outline button--icon"><?php i::_e('Ver Espaço'); ?></mc-link>
<button class="button button--secondarylight button--icon " @click="modal.close()"><?php i::_e('Completar Depois') ?></button>
<mc-link :entity="entity" route='edit' class="button button--primary button--icon"><?php i::_e('Completar Informações') ?></mc-link>
</template>
</mc-modal>
</mc-modal>
Loading