generic-skin 4.2.4 → 4.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/apps/vueChrono.js +9 -1
- package/apps/vueChrono.min.js +1 -1
- package/apps/vueMulti.js +5 -1
- package/apps/vueMulti.min.js +1 -1
- package/apps/vueRela.js +9 -1
- package/apps/vueRela.min.js +1 -1
- package/package.json +1 -1
package/apps/vueChrono.js
CHANGED
|
@@ -156,6 +156,14 @@ Vue.component('modal-cronologia', {
|
|
|
156
156
|
this.$parent.setEntry();
|
|
157
157
|
},
|
|
158
158
|
pushElement() {
|
|
159
|
+
if (!this.oneCheck.length) {
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
if (this.finalCheck) {
|
|
164
|
+
this.modalClose();
|
|
165
|
+
}
|
|
166
|
+
|
|
159
167
|
if (this.$parent.modal.type === 'edit') {
|
|
160
168
|
this.$parent.content.edit.splice(this.$parent.content.edit.map((item) => {
|
|
161
169
|
return item.position;
|
|
@@ -294,7 +302,7 @@ Vue.component('modal-cronologia', {
|
|
|
294
302
|
<template slot="controls">
|
|
295
303
|
<controles-modal>
|
|
296
304
|
<button class="button2" @click="page = 0" title="Paso anterior">Anterior</button>
|
|
297
|
-
<button class="button1 btn-main" @click="pushElement()"
|
|
305
|
+
<button class="button1 btn-main" @click="pushElement()" title="Guardar entrada">Guardar</button>
|
|
298
306
|
</controles-modal>
|
|
299
307
|
</template>
|
|
300
308
|
</template>
|
package/apps/vueChrono.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Vue.component("modal-cronologia",{props:["element","type"],data(){return{page:0,state:{modal:!1},info:{user:"",people:[],selector:!0},content:{edit:JSON.parse(JSON.stringify(this.element)),current:this.element}}},computed:{modalTitle(){return"new"===this.type?"Nueva entrada":"edit"===this.type?"Editar entrada":void 0},oneCheck(){let t="";if(!Object.keys(this.content.edit).length)return t;this.content.edit.name.length<5&&(t+="<li>Escribe un título lo suficientemente largo.</li>"),-1===this.content.edit.link.indexOf("/t")&&(t+="<li>Escribe un enlace válido.</li>");let e=[];if((1>parseFloat(this.content.edit.date.day)||parseFloat(this.content.edit.date.day)>forumData.date.day||""===this.content.edit.date.day||Number.isNaN(parseFloat(this.content.edit.date.day)))&&e.push("un día correcto (1 al "+forumData.date.day+")"),(1>parseFloat(this.content.edit.date.month)||parseFloat(this.content.edit.date.month)>forumData.date.month||""===this.content.edit.date.month||Number.isNaN(parseFloat(this.content.edit.date.month)))&&e.push("un mes correcto (1 al "+forumData.date.month+")"),("DFI"===this.content.edit.date.time&&parseFloat(this.content.edit.date.year)>forumData.date.year||"DFI"===this.content.edit.date.time&&parseFloat(this.content.edit.date.year)<1||""===this.content.edit.date.year||Number.isNaN(parseFloat(this.content.edit.date.year)))&&e.push("un año correcto"),-1===this.content.edit.date.time&&e.push("un periodo correcto"),e.length){let n="";n+="<li>Recuerda poner ",[].forEach.call(e,(t,e,a)=>{n+=t,a.length-2===e?n+=" y ":a.length===e+1?n+=".":a.length>e&&(n+=", ")}),n+="</li>",t+=n}return t},secondCheck(){let t="";return Object.keys(this.content.edit).length?(-1===this.content.edit.status&&(t+="<li>Selecciona un estado para el tema.</li>"),this.info.people.length||(t+="<li>Selecciona al menos un personaje.</li>"),t):t},finalCheck(){return JSON.stringify(this.content.current)!==JSON.stringify(this.finalData)},finalData(){let t=JSON.parse(JSON.stringify(this.content.edit));if(!Object.keys(this.content.edit).length)return t;let e="",n="";return[].forEach.call(JSON.parse(JSON.stringify(this.sortedEditCharacters)),(t,a,o)=>{e+=t,n+=Vue.filter("just-name")(t),o.length-2===a?(e+=" y ",n+=" y "):o.length===a+1?(e+="",n+=""):o.length>a&&(e+=", ",n+=", ")}),t.people.count=this.info.people.length,t.people.list=e,t.people.short=n,"new"===this.$parent.modal.type&&(t.position=this.$parent.content.edit.length),t},sortedCharacters(){return Object.keys(this.content.edit).length?this.$parent.users.map(t=>t.user).filter(t=>-1===this.info.people.indexOf(t)).filter(t=>t.toLowerCase().indexOf(this.info.user.toLowerCase())>-1):this.$parent.users.map(t=>t.user)},sortedEditCharacters(){return this.info.people.sort((t,e)=>t<e?-1:t>e?1:0)}},methods:{modalClose(){this.$parent.modal.type="new",this.$parent.modal.status=!1,this.$parent.setEntry()},pushElement(){"edit"===this.$parent.modal.type&&this.$parent.content.edit.splice(this.$parent.content.edit.map(t=>t.position).indexOf(this.content.current.position),1),this.$parent.content.edit.push(this.finalData),this.modalClose()},addCharacter(t){this.info.people.push(t),this.info.selector=!1,this.info.user="",setTimeout(()=>{this.info.selector=!0},250)},deleteCharacter(t){const e=JSON.parse(JSON.stringify(this.content.edit.status));this.info.people.splice(t,1),this.forceRerender(),this.content.edit.status=-1,this.content.edit.status=e}},created(){let t=[];""!==this.content.edit.people.list&&(t=-1===this.content.edit.people.list.indexOf(" y ")?[this.content.edit.people.list]:this.content.edit.people.list.split(" y ")[0].split(", ").concat(this.content.edit.people.list.split(" y ")[1])),this.info.people=t},template:'\n <modal-foro :title="modalTitle" @modal-close="modalClose()">\n <template v-if="page === 0">\n <template slot="content">\n <aviso-foro v-show="oneCheck.length">\n <ul v-html="oneCheck"></ul>\n </aviso-foro>\n <ul class="forum-fieldlist no-style">\n <li>\n <campo-foro name="Título">\n <input type="text" v-model="content.edit.name" placeholder="Escribe el nombre del tema." />\n </campo-foro>\n </li>\n <li>\n <campo-foro name="Enlace">\n <input type="text" v-model="content.edit.link" placeholder="Escribe el enlace del tema." />\n </campo-foro>\n </li>\n <li>\n <campo-foro name="Fecha">\n <div class="input-date">\n <div class="date-element date-dmy">\n <label>\n Día\n <input type="text" v-model="content.edit.date.day" placeholder="0" />\n </label>\n <label>\n Mes\n <input type="text" v-model="content.edit.date.month" placeholder="0" />\n </label>\n <label>\n Año\n <input type="text" v-model="content.edit.date.year" placeholder="0" />\n </label>\n </div>\n <div class="date-element not-show mt-4">\n <label>\n Periodo\n <div class="select-container">\n <select v-model="content.edit.date.time">\n <option value="-1" hidden>-</option>\n <option value="AFI">AFI</option>\n <option value="DFI">DFI</option>\n </select>\n </div>\n </label>\n </div>\n </div>\n </campo-foro>\n </li>\n </ul>\n </template>\n <template slot="controls" v-if="!oneCheck.length">\n <controles-modal>\n <button class="button1 btn-main" @click="page = 1" title="Paso siguiente">Siguiente</button>\n </controles-modal>\n </template>\n </template>\n <template v-else-if="page === 1">\n <template slot="content">\n <aviso-foro v-show="secondCheck.length">\n <ul v-html="secondCheck"></ul>\n </aviso-foro>\n <ul class="forum-fieldlist no-style">\n <li>\n <campo-foro name="Estado">\n <div class="select-container">\n <select v-model="content.edit.status">\n <option value="-1" selected="selected" hidden="hidden">Selecciona un estado para el tema</option>\n <option value="ropened">Activo</option>\n <option value="rclosed">Cerrado</option>\n <option value="rabandoned">Abandonado</option>\n </select>\n </div>\n </campo-foro>\n </li>\n <li>\n <campo-foro name="Personajes">\n <div class="character-selector">\n <input type="text" v-model="info.user" placeholder="Escribe el nombre de un personaje." />\n <ul class="no-style selector-list" v-if="sortedCharacters.length > 0 && info.selector">\n <li v-for="(character, index) in sortedCharacters" @click="addCharacter(character)" :title="\'Seleccionar «\' + character + \'»\'">{{ character }}<i class="fas fa-plus"></i></li>\n </ul>\n <a class="character-custom" @click="addCharacter(info.user)" v-if="info.user.length > 2" :title="\'Seleccionar «\' + info.user + \'»\'">\n <i class="fas fa-plus"></i>\n </a>\n </div>\n <ul v-if="info.people.length" class="no-style character-list">\n <li v-for="(character, index) in sortedEditCharacters" @click="deleteCharacter(index)" :title="\'Quitar \' + character"><i class="fas fa-times"></i> {{ character }}</li>\n </ul>\n </campo-foro>\n </li>\n </ul>\n </template>\n <template slot="controls">\n <controles-modal>\n <button class="button2" @click="page = 0" title="Paso anterior">Anterior</button>\n <button class="button1 btn-main" @click="pushElement()" v-if="!secondCheck.length && finalCheck" title="Guardar entrada">Guardar</button>\n </controles-modal>\n </template>\n </template>\n </modal-foro>\n '}),Vue.component("gestor-cronologia",{data:()=>({render:0,modal:{type:"new",status:!1},users:[],state:{page:0,pagination:0},entry:{},content:{edit:[],current:[]}}),computed:{sortedContent(){return JSON.parse(JSON.stringify(this.content.edit)).sort(({date:t,name:e},{date:n,name:a})=>{if(t.time!==n.time)return"AFI"===t.time?-1:1;const o="AFI"===t.time?n:t,i="AFI"===t.time?t:n;return parseFloat(t.year)!==parseFloat(n.year)?parseFloat(o.year)-parseFloat(i.year):parseFloat(t.month)!==parseFloat(n.month)?parseFloat(o.month)-parseFloat(i.month):parseFloat(t.day)!==parseFloat(n.day)?parseFloat(o.day)-parseFloat(i.day):e-a})},paginationContent(){const t=forumConfig.skinOptions.paginationDefault,e=Math.floor((this.sortedContent.length-1)/t)+1;let n=[];for(let t=0;t<e;t++)n.push(t);return this.forceRerender(),{pages:n,content:this.sortedContent.slice(this.state.pagination*t,(this.state.pagination+1)*t)}},finalCheck(){return JSON.stringify(this.content.current)!==JSON.stringify(this.content.edit)}},methods:{forceRerender(){this.render+=1},setEntry(){this.entry={link:"",name:"",status:-1,people:{list:"",short:"",count:0},date:{time:"DFI",day:"",month:"",year:""}}},addEntry(t){t.preventDefault(),this.modal.status=!0},save(t){t.preventDefault(),this.state.page=2;const e=this.sortedContent.map(t=>(void 0!==t.desc&&delete t.desc,void 0!==t.position&&delete t.position,t));FNR.user.profile.setData([{name:forumConfig.profileUser.cronoField,type:"textarea",value:JSON.stringify(e).replace(/"/g,"`")}]).then(t=>{t?(FNR.html.genNotification("Atención","Información actualizada sin inconvenientes.","fas fa-check"),setTimeout(()=>{window.location.reload()},2e3)):FNR.html.genNotification("Atención","Hubo un problema al actualizar. Dale otro intento.","fas fa-exclamation")})}},created(){FNR.user.profile.getData([{name:forumConfig.profileUser.cronoField,type:"textarea"}]).then(t=>{const e=FNR.utility.genArray(t[0].value).map((t,e)=>{let n=t;return n.position=e,n});this.content.edit=e,this.content.current=JSON.parse(JSON.stringify(e)),FNR.forum.getMembers().then(t=>{this.setEntry(),this.users=t,this.state.page=1})})},template:'\n <section id="forum-chronology" class="wiki-content is-dramatic">\n <div class="is-content">\n <h2>Cronología</h2>\n <hr />\n <p>En esta página podrás editar la cronología de tu personaje.</p>\n <p>Ante cualquier duda o problema, contacta con la administración.</p>\n </div>\n <separador-foro />\n <template v-if="state.page === 0">\n <cargando-foro text="Cargando utilidad…"></cargando-foro>\n </template>\n <template v-else-if="state.page === 1">\n <modal-cronologia v-if="modal.status" :type="modal.type" :element="entry"></modal-cronologia>\n <mando-foro id="upper-controls" app="true">\n <template slot="pagination" v-if="paginationContent.pages.length > 1">\n <a class="page-action" title="Ir a la página anterior" v-if="state.pagination > 0" @click="state.pagination -= 1">\n <i class="fas fa-chevron-left"></i>\n </a>\n <template v-for="page in paginationContent.pages">\n <strong v-if="page === state.pagination">{{ page + 1 }}</strong>\n <a class="page-link" :title="\'Ir a la página «\' + (page + 1) + \'»\'" v-else @click="state.pagination = page">{{ page + 1 }}</a>\n </template>\n <a class="page-action" title="Ir a la página siguiente" v-if="(state.pagination + 1) < paginationContent.pages.length" @click="state.pagination += 1">\n <i class="fas fa-chevron-right"></i>\n </a>\n </template>\n <template slot="controls">\n <li @click="addEntry($event)">\n <boton-foro url="#" name="Añadir" icon="fas fa-plus"></boton-foro>\n </li>\n <li v-if="finalCheck" @click="save($event)">\n <boton-foro url="#" name="Guardar" icon="fas fa-save" type="no-name"></boton-foro>\n </li>\n </template>\n </mando-foro>\n <section id="forum-rplist" class="forum-wikilist">\n <lista-temas-cabecera elements="[\'Temas\', \'Información\']"></lista-temas-cabecera>\n <ul :class="\'wikilist-contents no-style\' + (!paginationContent.content.length ? \' no-results\': \'\')" :key="render">\n <template v-if="!paginationContent.content.length">\n <li class="is-not-topic is-not-lastpost">\n <h6>No hay entradas en tu cronología</h6>\n </li>\n </template>\n <template v-else v-for="rp in paginationContent.content">\n <elemento-cronologia :element="rp" type="manager" :id="rp.position" />\n </template>\n </ul>\n </section>\n <mando-foro id="lower-controls" app="true">\n <template slot="pagination" v-if="paginationContent.pages.length > 1">\n <a class="page-action" title="Ir a la página anterior" v-if="state.pagination > 0" @click="state.pagination -= 1">\n <i class="fas fa-chevron-left"></i>\n </a>\n <template v-for="page in paginationContent.pages">\n <strong v-if="page === state.pagination">{{ page + 1 }}</strong>\n <a class="page-link" :title="\'Ir a la página «\' + (page + 1) + \'»\'" v-else @click="state.pagination = page">{{ page + 1 }}</a>\n </template>\n <a class="page-action" title="Ir a la página siguiente" v-if="(state.pagination + 1) < paginationContent.pages.length" @click="state.pagination += 1">\n <i class="fas fa-chevron-right"></i>\n </a>\n </template>\n <template slot="controls">\n <li @click="addEntry($event)">\n <boton-foro url="#" name="Añadir" icon="fas fa-plus"></boton-foro>\n </li>\n <li v-if="finalCheck" @click="save($event)">\n <boton-foro url="#" name="Guardar" icon="fas fa-save" type="no-name"></boton-foro>\n </li>\n </template>\n </mando-foro>\n </template>\n <template v-else-if="state.page === 2">\n <cargando-foro text="Actualizando información…"></cargando-foro>\n </template>\n </section>\n '}),Vue.component("elemento-cronologia",{props:["element","type","id"],data(){return{content:this.element}},methods:{deleteElement(){this.$parent.content.edit.splice(this.$parent.content.edit.map(t=>t.position).indexOf(this.id),1),0===this.$parent.paginationContent.content.length&&0!==this.$parent.state.pagination&&(this.$parent.state.pagination-=1),this.$parent.forceRerender()},editElement(){this.$parent.modal.type="edit",this.$parent.entry=this.content,this.$parent.modal.status=!0}},template:'\n <li class="rp-list">\n <template v-if="type === \'manager\'">\n <a class="rp-element rp-manager">\n <div class="rp-icon">\n <template v-if="content.status === \'ropened\'">\n <i class="fas fa-lock-open"></i>\n </template>\n <template v-else-if="content.status === \'rclosed\'">\n <i class="fas fa-lock"></i>\n </template>\n <template v-else-if="content.status === \'rabandoned\'">\n <i class="fas fa-times"></i>\n </template>\n </div>\n <div class="rp-content">\n <div class="rp-name">\n <span>{{ content.name }}</span>\n <small>\n {{ content.date.day | to-number | in-two-digits }}/{{ content.date.month | to-number | in-two-digits }}/{{ content.date.year | to-number | in-two-digits }} - <template v-if="content.people.count < 4">{{ content.people.short }}</template><template v-else>Invitados</template>\n </small>\n </div>\n <div class="rp-controls">\n <span @click="editElement()" title="Editar entrada">Editar</span> / <span @click="deleteElement()" title="Eliminar entrada">Eliminar</span>\n </div>\n </div>\n </a>\n </template>\n <template v-else-if="type === \'profile\'">\n <a class="rp-element" :href="content.link" target="_blank" :title="\'Ir al tema «\' + content.name + \'»\'">\n <div class="rp-icon">\n <template v-if="content.status === \'ropened\'">\n <i class="fas fa-lock-open"></i>\n </template>\n <template v-else-if="content.status === \'rclosed\'">\n <i class="fas fa-lock"></i>\n </template>\n <template v-else-if="content.status === \'rabandoned\'">\n <i class="fas fa-times"></i>\n </template>\n </div>\n <div class="rp-content">\n <div class="rp-name">\n <span>{{ content.name }}</span>\n <small>\n {{ content.date.day | to-number | in-two-digits }}/{{ content.date.month | to-number | in-two-digits }}/{{ content.date.year | to-number | in-two-digits }} - <template v-if="content.people.count < 4">{{ content.people.short }}</template><template v-else>Invitados</template>\n </small>\n </div>\n </div>\n </a>\n </template>\n </li>\n '});
|
|
1
|
+
Vue.component("modal-cronologia",{props:["element","type"],data(){return{page:0,state:{modal:!1},info:{user:"",people:[],selector:!0},content:{edit:JSON.parse(JSON.stringify(this.element)),current:this.element}}},computed:{modalTitle(){return"new"===this.type?"Nueva entrada":"edit"===this.type?"Editar entrada":void 0},oneCheck(){let t="";if(!Object.keys(this.content.edit).length)return t;this.content.edit.name.length<5&&(t+="<li>Escribe un título lo suficientemente largo.</li>"),-1===this.content.edit.link.indexOf("/t")&&(t+="<li>Escribe un enlace válido.</li>");let e=[];if((1>parseFloat(this.content.edit.date.day)||parseFloat(this.content.edit.date.day)>forumData.date.day||""===this.content.edit.date.day||Number.isNaN(parseFloat(this.content.edit.date.day)))&&e.push("un día correcto (1 al "+forumData.date.day+")"),(1>parseFloat(this.content.edit.date.month)||parseFloat(this.content.edit.date.month)>forumData.date.month||""===this.content.edit.date.month||Number.isNaN(parseFloat(this.content.edit.date.month)))&&e.push("un mes correcto (1 al "+forumData.date.month+")"),("DFI"===this.content.edit.date.time&&parseFloat(this.content.edit.date.year)>forumData.date.year||"DFI"===this.content.edit.date.time&&parseFloat(this.content.edit.date.year)<1||""===this.content.edit.date.year||Number.isNaN(parseFloat(this.content.edit.date.year)))&&e.push("un año correcto"),-1===this.content.edit.date.time&&e.push("un periodo correcto"),e.length){let n="";n+="<li>Recuerda poner ",[].forEach.call(e,(t,e,a)=>{n+=t,a.length-2===e?n+=" y ":a.length===e+1?n+=".":a.length>e&&(n+=", ")}),n+="</li>",t+=n}return t},secondCheck(){let t="";return Object.keys(this.content.edit).length?(-1===this.content.edit.status&&(t+="<li>Selecciona un estado para el tema.</li>"),this.info.people.length||(t+="<li>Selecciona al menos un personaje.</li>"),t):t},finalCheck(){return JSON.stringify(this.content.current)!==JSON.stringify(this.finalData)},finalData(){let t=JSON.parse(JSON.stringify(this.content.edit));if(!Object.keys(this.content.edit).length)return t;let e="",n="";return[].forEach.call(JSON.parse(JSON.stringify(this.sortedEditCharacters)),(t,a,o)=>{e+=t,n+=Vue.filter("just-name")(t),o.length-2===a?(e+=" y ",n+=" y "):o.length===a+1?(e+="",n+=""):o.length>a&&(e+=", ",n+=", ")}),t.people.count=this.info.people.length,t.people.list=e,t.people.short=n,"new"===this.$parent.modal.type&&(t.position=this.$parent.content.edit.length),t},sortedCharacters(){return Object.keys(this.content.edit).length?this.$parent.users.map(t=>t.user).filter(t=>-1===this.info.people.indexOf(t)).filter(t=>t.toLowerCase().indexOf(this.info.user.toLowerCase())>-1):this.$parent.users.map(t=>t.user)},sortedEditCharacters(){return this.info.people.sort((t,e)=>t<e?-1:t>e?1:0)}},methods:{modalClose(){this.$parent.modal.type="new",this.$parent.modal.status=!1,this.$parent.setEntry()},pushElement(){this.oneCheck.length&&(this.finalCheck&&this.modalClose(),"edit"===this.$parent.modal.type&&this.$parent.content.edit.splice(this.$parent.content.edit.map(t=>t.position).indexOf(this.content.current.position),1),this.$parent.content.edit.push(this.finalData),this.modalClose())},addCharacter(t){this.info.people.push(t),this.info.selector=!1,this.info.user="",setTimeout(()=>{this.info.selector=!0},250)},deleteCharacter(t){const e=JSON.parse(JSON.stringify(this.content.edit.status));this.info.people.splice(t,1),this.forceRerender(),this.content.edit.status=-1,this.content.edit.status=e}},created(){let t=[];""!==this.content.edit.people.list&&(t=-1===this.content.edit.people.list.indexOf(" y ")?[this.content.edit.people.list]:this.content.edit.people.list.split(" y ")[0].split(", ").concat(this.content.edit.people.list.split(" y ")[1])),this.info.people=t},template:'\n <modal-foro :title="modalTitle" @modal-close="modalClose()">\n <template v-if="page === 0">\n <template slot="content">\n <aviso-foro v-show="oneCheck.length">\n <ul v-html="oneCheck"></ul>\n </aviso-foro>\n <ul class="forum-fieldlist no-style">\n <li>\n <campo-foro name="Título">\n <input type="text" v-model="content.edit.name" placeholder="Escribe el nombre del tema." />\n </campo-foro>\n </li>\n <li>\n <campo-foro name="Enlace">\n <input type="text" v-model="content.edit.link" placeholder="Escribe el enlace del tema." />\n </campo-foro>\n </li>\n <li>\n <campo-foro name="Fecha">\n <div class="input-date">\n <div class="date-element date-dmy">\n <label>\n Día\n <input type="text" v-model="content.edit.date.day" placeholder="0" />\n </label>\n <label>\n Mes\n <input type="text" v-model="content.edit.date.month" placeholder="0" />\n </label>\n <label>\n Año\n <input type="text" v-model="content.edit.date.year" placeholder="0" />\n </label>\n </div>\n <div class="date-element not-show mt-4">\n <label>\n Periodo\n <div class="select-container">\n <select v-model="content.edit.date.time">\n <option value="-1" hidden>-</option>\n <option value="AFI">AFI</option>\n <option value="DFI">DFI</option>\n </select>\n </div>\n </label>\n </div>\n </div>\n </campo-foro>\n </li>\n </ul>\n </template>\n <template slot="controls" v-if="!oneCheck.length">\n <controles-modal>\n <button class="button1 btn-main" @click="page = 1" title="Paso siguiente">Siguiente</button>\n </controles-modal>\n </template>\n </template>\n <template v-else-if="page === 1">\n <template slot="content">\n <aviso-foro v-show="secondCheck.length">\n <ul v-html="secondCheck"></ul>\n </aviso-foro>\n <ul class="forum-fieldlist no-style">\n <li>\n <campo-foro name="Estado">\n <div class="select-container">\n <select v-model="content.edit.status">\n <option value="-1" selected="selected" hidden="hidden">Selecciona un estado para el tema</option>\n <option value="ropened">Activo</option>\n <option value="rclosed">Cerrado</option>\n <option value="rabandoned">Abandonado</option>\n </select>\n </div>\n </campo-foro>\n </li>\n <li>\n <campo-foro name="Personajes">\n <div class="character-selector">\n <input type="text" v-model="info.user" placeholder="Escribe el nombre de un personaje." />\n <ul class="no-style selector-list" v-if="sortedCharacters.length > 0 && info.selector">\n <li v-for="(character, index) in sortedCharacters" @click="addCharacter(character)" :title="\'Seleccionar «\' + character + \'»\'">{{ character }}<i class="fas fa-plus"></i></li>\n </ul>\n <a class="character-custom" @click="addCharacter(info.user)" v-if="info.user.length > 2" :title="\'Seleccionar «\' + info.user + \'»\'">\n <i class="fas fa-plus"></i>\n </a>\n </div>\n <ul v-if="info.people.length" class="no-style character-list">\n <li v-for="(character, index) in sortedEditCharacters" @click="deleteCharacter(index)" :title="\'Quitar \' + character"><i class="fas fa-times"></i> {{ character }}</li>\n </ul>\n </campo-foro>\n </li>\n </ul>\n </template>\n <template slot="controls">\n <controles-modal>\n <button class="button2" @click="page = 0" title="Paso anterior">Anterior</button>\n <button class="button1 btn-main" @click="pushElement()" title="Guardar entrada">Guardar</button>\n </controles-modal>\n </template>\n </template>\n </modal-foro>\n '}),Vue.component("gestor-cronologia",{data:()=>({render:0,modal:{type:"new",status:!1},users:[],state:{page:0,pagination:0},entry:{},content:{edit:[],current:[]}}),computed:{sortedContent(){return JSON.parse(JSON.stringify(this.content.edit)).sort(({date:t,name:e},{date:n,name:a})=>{if(t.time!==n.time)return"AFI"===t.time?-1:1;const o="AFI"===t.time?n:t,i="AFI"===t.time?t:n;return parseFloat(t.year)!==parseFloat(n.year)?parseFloat(o.year)-parseFloat(i.year):parseFloat(t.month)!==parseFloat(n.month)?parseFloat(o.month)-parseFloat(i.month):parseFloat(t.day)!==parseFloat(n.day)?parseFloat(o.day)-parseFloat(i.day):e-a})},paginationContent(){const t=forumConfig.skinOptions.paginationDefault,e=Math.floor((this.sortedContent.length-1)/t)+1;let n=[];for(let t=0;t<e;t++)n.push(t);return this.forceRerender(),{pages:n,content:this.sortedContent.slice(this.state.pagination*t,(this.state.pagination+1)*t)}},finalCheck(){return JSON.stringify(this.content.current)!==JSON.stringify(this.content.edit)}},methods:{forceRerender(){this.render+=1},setEntry(){this.entry={link:"",name:"",status:-1,people:{list:"",short:"",count:0},date:{time:"DFI",day:"",month:"",year:""}}},addEntry(t){t.preventDefault(),this.modal.status=!0},save(t){t.preventDefault(),this.state.page=2;const e=this.sortedContent.map(t=>(void 0!==t.desc&&delete t.desc,void 0!==t.position&&delete t.position,t));FNR.user.profile.setData([{name:forumConfig.profileUser.cronoField,type:"textarea",value:JSON.stringify(e).replace(/"/g,"`")}]).then(t=>{t?(FNR.html.genNotification("Atención","Información actualizada sin inconvenientes.","fas fa-check"),setTimeout(()=>{window.location.reload()},2e3)):FNR.html.genNotification("Atención","Hubo un problema al actualizar. Dale otro intento.","fas fa-exclamation")})}},created(){FNR.user.profile.getData([{name:forumConfig.profileUser.cronoField,type:"textarea"}]).then(t=>{const e=FNR.utility.genArray(t[0].value).map((t,e)=>{let n=t;return n.position=e,n});this.content.edit=e,this.content.current=JSON.parse(JSON.stringify(e)),FNR.forum.getMembers().then(t=>{this.setEntry(),this.users=t,this.state.page=1})})},template:'\n <section id="forum-chronology" class="wiki-content is-dramatic">\n <div class="is-content">\n <h2>Cronología</h2>\n <hr />\n <p>En esta página podrás editar la cronología de tu personaje.</p>\n <p>Ante cualquier duda o problema, contacta con la administración.</p>\n </div>\n <separador-foro />\n <template v-if="state.page === 0">\n <cargando-foro text="Cargando utilidad…"></cargando-foro>\n </template>\n <template v-else-if="state.page === 1">\n <modal-cronologia v-if="modal.status" :type="modal.type" :element="entry"></modal-cronologia>\n <mando-foro id="upper-controls" app="true">\n <template slot="pagination" v-if="paginationContent.pages.length > 1">\n <a class="page-action" title="Ir a la página anterior" v-if="state.pagination > 0" @click="state.pagination -= 1">\n <i class="fas fa-chevron-left"></i>\n </a>\n <template v-for="page in paginationContent.pages">\n <strong v-if="page === state.pagination">{{ page + 1 }}</strong>\n <a class="page-link" :title="\'Ir a la página «\' + (page + 1) + \'»\'" v-else @click="state.pagination = page">{{ page + 1 }}</a>\n </template>\n <a class="page-action" title="Ir a la página siguiente" v-if="(state.pagination + 1) < paginationContent.pages.length" @click="state.pagination += 1">\n <i class="fas fa-chevron-right"></i>\n </a>\n </template>\n <template slot="controls">\n <li @click="addEntry($event)">\n <boton-foro url="#" name="Añadir" icon="fas fa-plus"></boton-foro>\n </li>\n <li v-if="finalCheck" @click="save($event)">\n <boton-foro url="#" name="Guardar" icon="fas fa-save" type="no-name"></boton-foro>\n </li>\n </template>\n </mando-foro>\n <section id="forum-rplist" class="forum-wikilist">\n <lista-temas-cabecera elements="[\'Temas\', \'Información\']"></lista-temas-cabecera>\n <ul :class="\'wikilist-contents no-style\' + (!paginationContent.content.length ? \' no-results\': \'\')" :key="render">\n <template v-if="!paginationContent.content.length">\n <li class="is-not-topic is-not-lastpost">\n <h6>No hay entradas en tu cronología</h6>\n </li>\n </template>\n <template v-else v-for="rp in paginationContent.content">\n <elemento-cronologia :element="rp" type="manager" :id="rp.position" />\n </template>\n </ul>\n </section>\n <mando-foro id="lower-controls" app="true">\n <template slot="pagination" v-if="paginationContent.pages.length > 1">\n <a class="page-action" title="Ir a la página anterior" v-if="state.pagination > 0" @click="state.pagination -= 1">\n <i class="fas fa-chevron-left"></i>\n </a>\n <template v-for="page in paginationContent.pages">\n <strong v-if="page === state.pagination">{{ page + 1 }}</strong>\n <a class="page-link" :title="\'Ir a la página «\' + (page + 1) + \'»\'" v-else @click="state.pagination = page">{{ page + 1 }}</a>\n </template>\n <a class="page-action" title="Ir a la página siguiente" v-if="(state.pagination + 1) < paginationContent.pages.length" @click="state.pagination += 1">\n <i class="fas fa-chevron-right"></i>\n </a>\n </template>\n <template slot="controls">\n <li @click="addEntry($event)">\n <boton-foro url="#" name="Añadir" icon="fas fa-plus"></boton-foro>\n </li>\n <li v-if="finalCheck" @click="save($event)">\n <boton-foro url="#" name="Guardar" icon="fas fa-save" type="no-name"></boton-foro>\n </li>\n </template>\n </mando-foro>\n </template>\n <template v-else-if="state.page === 2">\n <cargando-foro text="Actualizando información…"></cargando-foro>\n </template>\n </section>\n '}),Vue.component("elemento-cronologia",{props:["element","type","id"],data(){return{content:this.element}},methods:{deleteElement(){this.$parent.content.edit.splice(this.$parent.content.edit.map(t=>t.position).indexOf(this.id),1),0===this.$parent.paginationContent.content.length&&0!==this.$parent.state.pagination&&(this.$parent.state.pagination-=1),this.$parent.forceRerender()},editElement(){this.$parent.modal.type="edit",this.$parent.entry=this.content,this.$parent.modal.status=!0}},template:'\n <li class="rp-list">\n <template v-if="type === \'manager\'">\n <a class="rp-element rp-manager">\n <div class="rp-icon">\n <template v-if="content.status === \'ropened\'">\n <i class="fas fa-lock-open"></i>\n </template>\n <template v-else-if="content.status === \'rclosed\'">\n <i class="fas fa-lock"></i>\n </template>\n <template v-else-if="content.status === \'rabandoned\'">\n <i class="fas fa-times"></i>\n </template>\n </div>\n <div class="rp-content">\n <div class="rp-name">\n <span>{{ content.name }}</span>\n <small>\n {{ content.date.day | to-number | in-two-digits }}/{{ content.date.month | to-number | in-two-digits }}/{{ content.date.year | to-number | in-two-digits }} - <template v-if="content.people.count < 4">{{ content.people.short }}</template><template v-else>Invitados</template>\n </small>\n </div>\n <div class="rp-controls">\n <span @click="editElement()" title="Editar entrada">Editar</span> / <span @click="deleteElement()" title="Eliminar entrada">Eliminar</span>\n </div>\n </div>\n </a>\n </template>\n <template v-else-if="type === \'profile\'">\n <a class="rp-element" :href="content.link" target="_blank" :title="\'Ir al tema «\' + content.name + \'»\'">\n <div class="rp-icon">\n <template v-if="content.status === \'ropened\'">\n <i class="fas fa-lock-open"></i>\n </template>\n <template v-else-if="content.status === \'rclosed\'">\n <i class="fas fa-lock"></i>\n </template>\n <template v-else-if="content.status === \'rabandoned\'">\n <i class="fas fa-times"></i>\n </template>\n </div>\n <div class="rp-content">\n <div class="rp-name">\n <span>{{ content.name }}</span>\n <small>\n {{ content.date.day | to-number | in-two-digits }}/{{ content.date.month | to-number | in-two-digits }}/{{ content.date.year | to-number | in-two-digits }} - <template v-if="content.people.count < 4">{{ content.people.short }}</template><template v-else>Invitados</template>\n </small>\n </div>\n </div>\n </a>\n </template>\n </li>\n '});
|
package/apps/vueMulti.js
CHANGED
|
@@ -50,6 +50,10 @@ Vue.component('modal-multicuentas', {
|
|
|
50
50
|
this.$parent.forceRerender();
|
|
51
51
|
},
|
|
52
52
|
pushElement() {
|
|
53
|
+
if (!this.oneCheck.length) {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
|
|
53
57
|
if (this.$parent.modal.type === 'edit') {
|
|
54
58
|
let id = this.$parent.content.accounts.edit.map((item) => {
|
|
55
59
|
return item.id;
|
|
@@ -98,7 +102,7 @@ Vue.component('modal-multicuentas', {
|
|
|
98
102
|
</ul>
|
|
99
103
|
</template>
|
|
100
104
|
<template slot="controls">
|
|
101
|
-
<controles-modal
|
|
105
|
+
<controles-modal>
|
|
102
106
|
<button class="button1 btn-main" @click="pushElement()" title="Guardar entrada">Guardar</button>
|
|
103
107
|
</controles-modal>
|
|
104
108
|
</template>
|
package/apps/vueMulti.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Vue.component("modal-multicuentas",{props:["element","type"],data(){return{state:{modal:!1},content:{edit:JSON.parse(JSON.stringify(this.element)),current:this.element}}},computed:{modalTitle(){return"new"===this.type?"Nuevo usuario":"edit"===this.type?"Editar usuario":void 0},oneCheck(){let t="";return this.content.edit.name.length<4&&(t+="<li>Escribe el nombre de la cuenta.</li>"),this.content.edit.password.length<4&&(t+="<li>Escribe la contraseña de la cuenta.</li>"),t},finalCheck(){const{name:t,password:e}=this.content.current,{name:n,password:a}=this.content.edit;return t!==n||e!==a}},methods:{modalClose(){this.$parent.modal.type="new",this.$parent.modal.status=!1,this.$parent.setEntry(),this.$parent.forceRerender()},pushElement(){if("edit"===this.$parent.modal.type){let t=this.$parent.content.accounts.edit.map(t=>t.id).indexOf(this.content.current.id);this.$parent.content.accounts.edit.splice(t,1)}this.$parent.content.accounts.edit.push({name:this.content.edit.name,type:"password",id:FNR.utility.genSlug(this.content.edit.name),password:this.content.edit.password}),this.modalClose()}},template:'\n <modal-foro :title="modalTitle" @modal-close="modalClose()">\n <template slot="content">\n <aviso-foro v-show="oneCheck.length">\n <ul v-html="oneCheck"></ul>\n </aviso-foro>\n <ul class="forum-fieldlist no-style">\n <li>\n <campo-foro name="Nombre">\n <input type="text" v-model="content.edit.name" placeholder="Escribe el nombre de la cuenta." />\n </campo-foro>\n </li>\n <li>\n <campo-foro name="Contraseña">\n <div class="character-selector">\n <input :type="content.edit.type" v-model="content.edit.password" placeholder="Escribe la contraseña de la cuenta." />\n <a class="character-custom" @click="content.edit.type === \'text\' ? content.edit.type = \'password\' : content.edit.type = \'text\'" title="Cambiar modo">\n <template v-if="content.edit.type === \'text\'">\n <i class="fas fa-eye-slash"></i>\n </template>\n <template v-else-if="content.edit.type === \'password\'">\n <i class="fas fa-eye"></i>\n </template>\n </a>\n </div>\n </campo-foro>\n </li>\n </ul>\n </template>\n <template slot="controls">\n <controles-modal v-if="!oneCheck.length && finalCheck">\n <button class="button1 btn-main" @click="pushElement()" title="Guardar entrada">Guardar</button>\n </controles-modal>\n </template>\n </modal-foro>\n '}),Vue.component("gestor-multicuentas",{data:()=>({render:0,modal:{type:"new",status:!1,bonus:!1},state:{new:!1,error:!1,page:0,pagination:0},entry:{},content:{page:1,default:forumConfig.skinOptions.paginationDefault,loading:1,encrypted:{},password:{type:"password",value:""},accounts:{current:[],edit:[]}}}),computed:{msgCheck(){let t="";return this.content.password.value.length<5&&(t+="<li>Escribe la contraseña maestra.</li>"),t},finalCheck(){return JSON.stringify(this.content.accounts.current)!==JSON.stringify(this.content.accounts.edit)},sortedCharacters(){return this.content.accounts.edit.sort((t,e)=>t.name<e.name?-1:t.name>e.name?1:0).slice((this.content.page-1)*this.content.default,this.content.page*this.content.default)}},methods:{modalClose(){this.state.page=3,setTimeout(()=>{window.location.reload()},2500)},forceRerender(){this.render+=1},setEntry(){this.entry={name:"",id:"",type:"password",password:""}},addEntry(t){t.preventDefault(),this.modal.status=!0},save(t){t.preventDefault(),this.updateData()},updateLocal(){this.updateData()},updateForum(){this.content.accounts.edit=FNR.cache.getData("usermultiaccounts").map(t=>({name:t.name,password:sjcl.decrypt(this.content.password.value,t.password)})),this.updateData()},setData(){this.state.page=3,FNR.cache.setData("userpassword",this.content.password.value,-1),setTimeout(()=>{window.location.reload()},2500)},setPage(t){this.content.loading=0,this.content.page=t,this.forceRerender(),setTimeout(()=>{this.content.loading=1},350)},updateData(){this.state.page=3;const t=this.content.accounts.edit.map(t=>({name:t.name,password:sjcl.encrypt(this.content.password.value,t.password)}));FNR.cache.setData("userpassword",this.content.password.value,-1),FNR.cache.setData("usermultiaccounts",t,-1),FNR.user.profile.setData([{name:forumConfig.profileUser.accountsField,type:"textarea",value:JSON.stringify([{password:this.state.new?sjcl.encrypt(this.content.password.value,"gaylien_masterpass"):this.content.encrypted.password,accounts:t}]).replace(/"/g,"`")}]).then(t=>{t?(FNR.html.genNotification("Atención","Información actualizada sin inconvenientes.","fas fa-check"),setTimeout(()=>{window.location.reload()},2500)):FNR.html.genNotification("Atención","Hubo un problema al actualizar. Dale otro intento.","fas fa-exclamation")})}},created(){FNR.user.profile.getData([{name:forumConfig.profileUser.accountsField,type:"textarea"}]).then(t=>{if(this.content.encrypted=FNR.utility.genArray(t[0].value)[0],this.state.new=0===Object.keys(this.content.encrypted).length,FNR.cache.getData("userpassword"))try{sjcl.decrypt(FNR.cache.getData("userpassword"),this.content.encrypted.password)}catch(t){"ccm: tag doesn't match"===t.message&&(this.state.error=!0,FNR.cache.delData("userpassword"),setTimeout(()=>{window.location.reload()},2500))}finally{if(!this.state.error)if(this.state.new&&FNR.cache.getData("usermultiaccounts").length>0)this.state.page=3,FNR.user.profile.setData([{name:forumConfig.profileUser.accountsField,type:"textarea",value:JSON.stringify([{password:sjcl.encrypt(FNR.cache.getData("userpassword"),"gaylien_masterpass"),accounts:FNR.cache.getData("usermultiaccounts")}]).replace(/"/g,"`")}]).then(t=>{t?(FNR.html.genNotification("Atención","Información actualizada sin inconvenientes.","fas fa-check"),setTimeout(()=>{window.location.reload()},2500)):FNR.html.genNotification("Atención","Hubo un problema al actualizar. Dale otro intento.","fas fa-exclamation")});else{let t=[];this.content.password.value=FNR.cache.getData("userpassword"),this.state.new||(t=JSON.parse(JSON.stringify(this.content.encrypted)).accounts.map(t=>({name:t.name,type:"password",id:FNR.utility.genSlug(t.name),password:sjcl.decrypt(this.content.password.value,t.password)}))),this.setEntry(),this.content.accounts.edit=t,this.content.accounts.current=JSON.parse(JSON.stringify(t)),this.state.page=2,this.state.new||JSON.stringify(FNR.cache.getData("usermultiaccounts"))===JSON.stringify(this.content.encrypted.accounts)||(this.modal.bonus=!0)}}else this.state.page=1})},template:'\n <section id="forum-multiaccount" class="wiki-content is-dramatic">\n <div class="is-content">\n <h2>Multicuentas</h2>\n <hr />\n <p>En esta página podrás configurar tu cambio de cuenta rápido.</p>\n <p>Ante cualquier duda o problema, contacta con la administración.</p>\n </div>\n <separador-foro />\n <template v-if="state.page === 0">\n <cargando-foro text="Cargando utilidad…"></cargando-foro>\n </template>\n <template v-else-if="state.page === 1">\n <section class="forum-wikilist">\n <aviso-foro v-show="msgCheck.length">\n <ul v-html="msgCheck"></ul>\n </aviso-foro>\n <ul class="forum-fieldlist no-style">\n <li>\n <campo-foro name="Contraseña maestra">\n <div class="character-selector">\n <input :type="content.password.type" v-model="content.password.value" />\n <a class="character-custom" @click="content.password.type === \'text\' ? content.password.type = \'password\' : content.password.type = \'text\'" title="Cambiar modo">\n <template v-if="content.password.type === \'text\'">\n <i class="fas fa-eye-slash"></i>\n </template>\n <template v-else-if="content.password.type === \'password\'">\n <i class="fas fa-eye"></i>\n </template>\n </a>\n </div>\n </campo-foro>\n </li>\n </ul>\n <div id="usereply-comand" v-if="!msgCheck.length">\n <button class="button1 btn-main" @click="setData()">Guardar</button>\n </div>\n </section>\n </template>\n <template v-else-if="state.page === 2">\n <modal-multicuentas v-if="modal.status" :type="modal.type" :element="entry"></modal-multicuentas>\n <modal-foro v-if="modal.bonus" title="Atención" @modal-close="modalClose()">\n <template slot="content">\n <p>Hemos detectado que tienes dos versiones de tu base de datos de cuentas asociadas diferentes. Por favor, elige o actualizar la del dispositivo o la del foro.</p>\n </template>\n <template slot="controls">\n <controles-modal>\n <button class="button1 btn-main" @click="updateForum()" title="Actualizar versión foro">Actualizar foro</button>\n <button class="button1" @click="updateLocal()" title="Actualizar versión local">Actualizar local</button>\n </controles-modal>\n </template>\n </modal-foro>\n <mando-foro id="upper-controls" app="true">\n <template slot="pagination" v-if="content.accounts.edit.length > 1">\n <paginacion-foro :page="content.page" :total="Math.ceil(content.accounts.edit.length / content.default)" @setPage="setPage" />\n </template>\n <template slot="controls">\n <li @click="addEntry($event)">\n <boton-foro url="#" name="Añadir" icon="fas fa-plus"></boton-foro>\n </li>\n <li v-if="finalCheck" @click="save($event)">\n <boton-foro url="#" name="Guardar" icon="fas fa-save" type="no-name"></boton-foro>\n </li>\n </template>\n </mando-foro>\n <section id="forum-accountlist" class="forum-wikilist">\n <lista-temas-cabecera elements="[\'Cuentas\', \'Información\']"></lista-temas-cabecera>\n <ul :class="\'wikilist-contents no-style\' + (!sortedCharacters.length || content.loading === 0 ? \' no-results\': \'\')" :key="render">\n <template v-if="!sortedCharacters.length">\n <li class="is-not-topic is-not-lastpost">\n <h6>No hay cuentas configuradas</h6>\n </li>\n </template>\n <template v-else-if="content.loading === 0">\n <li class="is-not-topic is-not-lastpost">\n <cargando-foro text="Cargando cuentas…"></cargando-foro>\n </li>\n </template>\n <template v-else v-for="(item, index) in sortedCharacters">\n <elemento-multicuentas :element="item" :id="index" :key="index"></elemento-multicuentas>\n </template>\n </ul>\n </section>\n <mando-foro id="lower-controls" app="true">\n <template slot="pagination" v-if="sortedCharacters.length > 1">\n <paginacion-foro :page="content.page" :total="Math.ceil(content.accounts.edit.length / content.default)" @setPage="setPage" />\n </template>\n <template slot="controls">\n <li @click="addEntry($event)">\n <boton-foro url="#" name="Añadir" icon="fas fa-plus"></boton-foro>\n </li>\n <li v-if="finalCheck" @click="save($event)">\n <boton-foro url="#" name="Guardar" icon="fas fa-save" type="no-name"></boton-foro>\n </li>\n </template>\n </mando-foro>\n </template>\n <template v-else-if="state.page === 3">\n <cargando-foro text="Actualizando información…"></cargando-foro>\n </template>\n </section>\n '}),Vue.component("elemento-multicuentas",{props:["element","id"],data(){return{content:this.element}},methods:{deleteElement(){FNR.html.genPrompt("Necesitamos confirmación","Te dispones a eliminar una cuenta almacenada en el gestor. ¿Estás segur@?","Escribe «ELIMINAR» para confirmar","").then(t=>{"ELIMINAR"===t&&(this.$parent.content.accounts.edit.splice(this.id,1),this.$parent.forceRerender())})},editElement(){this.$parent.modal.type="edit",this.$parent.entry=this.content,this.$parent.modal.status=!0}},template:'\n <li>\n <campo-foro :name="content.name">\n <div class="character-selector">\n <input :type="content.type" v-model="content.password" disabled/>\n <span class="character-custom rp-controls">\n <span @click="editElement()" title="Editar entrada">Editar</span> / <span @click="deleteElement()" title="Eliminar entrada">Eliminar</span>\n </span>\n </div>\n </campo-foro>\n </li>\n '});
|
|
1
|
+
Vue.component("modal-multicuentas",{props:["element","type"],data(){return{state:{modal:!1},content:{edit:JSON.parse(JSON.stringify(this.element)),current:this.element}}},computed:{modalTitle(){return"new"===this.type?"Nuevo usuario":"edit"===this.type?"Editar usuario":void 0},oneCheck(){let t="";return this.content.edit.name.length<4&&(t+="<li>Escribe el nombre de la cuenta.</li>"),this.content.edit.password.length<4&&(t+="<li>Escribe la contraseña de la cuenta.</li>"),t},finalCheck(){const{name:t,password:e}=this.content.current,{name:n,password:a}=this.content.edit;return t!==n||e!==a}},methods:{modalClose(){this.$parent.modal.type="new",this.$parent.modal.status=!1,this.$parent.setEntry(),this.$parent.forceRerender()},pushElement(){if(this.oneCheck.length){if("edit"===this.$parent.modal.type){let t=this.$parent.content.accounts.edit.map(t=>t.id).indexOf(this.content.current.id);this.$parent.content.accounts.edit.splice(t,1)}this.$parent.content.accounts.edit.push({name:this.content.edit.name,type:"password",id:FNR.utility.genSlug(this.content.edit.name),password:this.content.edit.password}),this.modalClose()}}},template:'\n <modal-foro :title="modalTitle" @modal-close="modalClose()">\n <template slot="content">\n <aviso-foro v-show="oneCheck.length">\n <ul v-html="oneCheck"></ul>\n </aviso-foro>\n <ul class="forum-fieldlist no-style">\n <li>\n <campo-foro name="Nombre">\n <input type="text" v-model="content.edit.name" placeholder="Escribe el nombre de la cuenta." />\n </campo-foro>\n </li>\n <li>\n <campo-foro name="Contraseña">\n <div class="character-selector">\n <input :type="content.edit.type" v-model="content.edit.password" placeholder="Escribe la contraseña de la cuenta." />\n <a class="character-custom" @click="content.edit.type === \'text\' ? content.edit.type = \'password\' : content.edit.type = \'text\'" title="Cambiar modo">\n <template v-if="content.edit.type === \'text\'">\n <i class="fas fa-eye-slash"></i>\n </template>\n <template v-else-if="content.edit.type === \'password\'">\n <i class="fas fa-eye"></i>\n </template>\n </a>\n </div>\n </campo-foro>\n </li>\n </ul>\n </template>\n <template slot="controls">\n <controles-modal>\n <button class="button1 btn-main" @click="pushElement()" title="Guardar entrada">Guardar</button>\n </controles-modal>\n </template>\n </modal-foro>\n '}),Vue.component("gestor-multicuentas",{data:()=>({render:0,modal:{type:"new",status:!1,bonus:!1},state:{new:!1,error:!1,page:0,pagination:0},entry:{},content:{page:1,default:forumConfig.skinOptions.paginationDefault,loading:1,encrypted:{},password:{type:"password",value:""},accounts:{current:[],edit:[]}}}),computed:{msgCheck(){let t="";return this.content.password.value.length<5&&(t+="<li>Escribe la contraseña maestra.</li>"),t},finalCheck(){return JSON.stringify(this.content.accounts.current)!==JSON.stringify(this.content.accounts.edit)},sortedCharacters(){return this.content.accounts.edit.sort((t,e)=>t.name<e.name?-1:t.name>e.name?1:0).slice((this.content.page-1)*this.content.default,this.content.page*this.content.default)}},methods:{modalClose(){this.state.page=3,setTimeout(()=>{window.location.reload()},2500)},forceRerender(){this.render+=1},setEntry(){this.entry={name:"",id:"",type:"password",password:""}},addEntry(t){t.preventDefault(),this.modal.status=!0},save(t){t.preventDefault(),this.updateData()},updateLocal(){this.updateData()},updateForum(){this.content.accounts.edit=FNR.cache.getData("usermultiaccounts").map(t=>({name:t.name,password:sjcl.decrypt(this.content.password.value,t.password)})),this.updateData()},setData(){this.state.page=3,FNR.cache.setData("userpassword",this.content.password.value,-1),setTimeout(()=>{window.location.reload()},2500)},setPage(t){this.content.loading=0,this.content.page=t,this.forceRerender(),setTimeout(()=>{this.content.loading=1},350)},updateData(){this.state.page=3;const t=this.content.accounts.edit.map(t=>({name:t.name,password:sjcl.encrypt(this.content.password.value,t.password)}));FNR.cache.setData("userpassword",this.content.password.value,-1),FNR.cache.setData("usermultiaccounts",t,-1),FNR.user.profile.setData([{name:forumConfig.profileUser.accountsField,type:"textarea",value:JSON.stringify([{password:this.state.new?sjcl.encrypt(this.content.password.value,"gaylien_masterpass"):this.content.encrypted.password,accounts:t}]).replace(/"/g,"`")}]).then(t=>{t?(FNR.html.genNotification("Atención","Información actualizada sin inconvenientes.","fas fa-check"),setTimeout(()=>{window.location.reload()},2500)):FNR.html.genNotification("Atención","Hubo un problema al actualizar. Dale otro intento.","fas fa-exclamation")})}},created(){FNR.user.profile.getData([{name:forumConfig.profileUser.accountsField,type:"textarea"}]).then(t=>{if(this.content.encrypted=FNR.utility.genArray(t[0].value)[0],this.state.new=0===Object.keys(this.content.encrypted).length,FNR.cache.getData("userpassword"))try{sjcl.decrypt(FNR.cache.getData("userpassword"),this.content.encrypted.password)}catch(t){"ccm: tag doesn't match"===t.message&&(this.state.error=!0,FNR.cache.delData("userpassword"),setTimeout(()=>{window.location.reload()},2500))}finally{if(!this.state.error)if(this.state.new&&FNR.cache.getData("usermultiaccounts").length>0)this.state.page=3,FNR.user.profile.setData([{name:forumConfig.profileUser.accountsField,type:"textarea",value:JSON.stringify([{password:sjcl.encrypt(FNR.cache.getData("userpassword"),"gaylien_masterpass"),accounts:FNR.cache.getData("usermultiaccounts")}]).replace(/"/g,"`")}]).then(t=>{t?(FNR.html.genNotification("Atención","Información actualizada sin inconvenientes.","fas fa-check"),setTimeout(()=>{window.location.reload()},2500)):FNR.html.genNotification("Atención","Hubo un problema al actualizar. Dale otro intento.","fas fa-exclamation")});else{let t=[];this.content.password.value=FNR.cache.getData("userpassword"),this.state.new||(t=JSON.parse(JSON.stringify(this.content.encrypted)).accounts.map(t=>({name:t.name,type:"password",id:FNR.utility.genSlug(t.name),password:sjcl.decrypt(this.content.password.value,t.password)}))),this.setEntry(),this.content.accounts.edit=t,this.content.accounts.current=JSON.parse(JSON.stringify(t)),this.state.page=2,this.state.new||JSON.stringify(FNR.cache.getData("usermultiaccounts"))===JSON.stringify(this.content.encrypted.accounts)||(this.modal.bonus=!0)}}else this.state.page=1})},template:'\n <section id="forum-multiaccount" class="wiki-content is-dramatic">\n <div class="is-content">\n <h2>Multicuentas</h2>\n <hr />\n <p>En esta página podrás configurar tu cambio de cuenta rápido.</p>\n <p>Ante cualquier duda o problema, contacta con la administración.</p>\n </div>\n <separador-foro />\n <template v-if="state.page === 0">\n <cargando-foro text="Cargando utilidad…"></cargando-foro>\n </template>\n <template v-else-if="state.page === 1">\n <section class="forum-wikilist">\n <aviso-foro v-show="msgCheck.length">\n <ul v-html="msgCheck"></ul>\n </aviso-foro>\n <ul class="forum-fieldlist no-style">\n <li>\n <campo-foro name="Contraseña maestra">\n <div class="character-selector">\n <input :type="content.password.type" v-model="content.password.value" />\n <a class="character-custom" @click="content.password.type === \'text\' ? content.password.type = \'password\' : content.password.type = \'text\'" title="Cambiar modo">\n <template v-if="content.password.type === \'text\'">\n <i class="fas fa-eye-slash"></i>\n </template>\n <template v-else-if="content.password.type === \'password\'">\n <i class="fas fa-eye"></i>\n </template>\n </a>\n </div>\n </campo-foro>\n </li>\n </ul>\n <div id="usereply-comand" v-if="!msgCheck.length">\n <button class="button1 btn-main" @click="setData()">Guardar</button>\n </div>\n </section>\n </template>\n <template v-else-if="state.page === 2">\n <modal-multicuentas v-if="modal.status" :type="modal.type" :element="entry"></modal-multicuentas>\n <modal-foro v-if="modal.bonus" title="Atención" @modal-close="modalClose()">\n <template slot="content">\n <p>Hemos detectado que tienes dos versiones de tu base de datos de cuentas asociadas diferentes. Por favor, elige o actualizar la del dispositivo o la del foro.</p>\n </template>\n <template slot="controls">\n <controles-modal>\n <button class="button1 btn-main" @click="updateForum()" title="Actualizar versión foro">Actualizar foro</button>\n <button class="button1" @click="updateLocal()" title="Actualizar versión local">Actualizar local</button>\n </controles-modal>\n </template>\n </modal-foro>\n <mando-foro id="upper-controls" app="true">\n <template slot="pagination" v-if="content.accounts.edit.length > 1">\n <paginacion-foro :page="content.page" :total="Math.ceil(content.accounts.edit.length / content.default)" @setPage="setPage" />\n </template>\n <template slot="controls">\n <li @click="addEntry($event)">\n <boton-foro url="#" name="Añadir" icon="fas fa-plus"></boton-foro>\n </li>\n <li v-if="finalCheck" @click="save($event)">\n <boton-foro url="#" name="Guardar" icon="fas fa-save" type="no-name"></boton-foro>\n </li>\n </template>\n </mando-foro>\n <section id="forum-accountlist" class="forum-wikilist">\n <lista-temas-cabecera elements="[\'Cuentas\', \'Información\']"></lista-temas-cabecera>\n <ul :class="\'wikilist-contents no-style\' + (!sortedCharacters.length || content.loading === 0 ? \' no-results\': \'\')" :key="render">\n <template v-if="!sortedCharacters.length">\n <li class="is-not-topic is-not-lastpost">\n <h6>No hay cuentas configuradas</h6>\n </li>\n </template>\n <template v-else-if="content.loading === 0">\n <li class="is-not-topic is-not-lastpost">\n <cargando-foro text="Cargando cuentas…"></cargando-foro>\n </li>\n </template>\n <template v-else v-for="(item, index) in sortedCharacters">\n <elemento-multicuentas :element="item" :id="index" :key="index"></elemento-multicuentas>\n </template>\n </ul>\n </section>\n <mando-foro id="lower-controls" app="true">\n <template slot="pagination" v-if="sortedCharacters.length > 1">\n <paginacion-foro :page="content.page" :total="Math.ceil(content.accounts.edit.length / content.default)" @setPage="setPage" />\n </template>\n <template slot="controls">\n <li @click="addEntry($event)">\n <boton-foro url="#" name="Añadir" icon="fas fa-plus"></boton-foro>\n </li>\n <li v-if="finalCheck" @click="save($event)">\n <boton-foro url="#" name="Guardar" icon="fas fa-save" type="no-name"></boton-foro>\n </li>\n </template>\n </mando-foro>\n </template>\n <template v-else-if="state.page === 3">\n <cargando-foro text="Actualizando información…"></cargando-foro>\n </template>\n </section>\n '}),Vue.component("elemento-multicuentas",{props:["element","id"],data(){return{content:this.element}},methods:{deleteElement(){FNR.html.genPrompt("Necesitamos confirmación","Te dispones a eliminar una cuenta almacenada en el gestor. ¿Estás segur@?","Escribe «ELIMINAR» para confirmar","").then(t=>{"ELIMINAR"===t&&(this.$parent.content.accounts.edit.splice(this.id,1),this.$parent.forceRerender())})},editElement(){this.$parent.modal.type="edit",this.$parent.entry=this.content,this.$parent.modal.status=!0}},template:'\n <li>\n <campo-foro :name="content.name">\n <div class="character-selector">\n <input :type="content.type" v-model="content.password" disabled/>\n <span class="character-custom rp-controls">\n <span @click="editElement()" title="Editar entrada">Editar</span> / <span @click="deleteElement()" title="Eliminar entrada">Eliminar</span>\n </span>\n </div>\n </campo-foro>\n </li>\n '});
|
package/apps/vueRela.js
CHANGED
|
@@ -83,6 +83,14 @@ Vue.component('modal-relaciones', {
|
|
|
83
83
|
this.content.edit.img = data.img;
|
|
84
84
|
},
|
|
85
85
|
pushElement() {
|
|
86
|
+
if (!this.oneCheck.length) {
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
if (this.finalCheck) {
|
|
91
|
+
this.modalClose();
|
|
92
|
+
}
|
|
93
|
+
|
|
86
94
|
if (this.$parent.modal.type === 'edit') {
|
|
87
95
|
this.$parent.content.edit.splice(this.$parent.content.edit.map((item) => {
|
|
88
96
|
return item.position;
|
|
@@ -128,7 +136,7 @@ Vue.component('modal-relaciones', {
|
|
|
128
136
|
</li>
|
|
129
137
|
</ul>
|
|
130
138
|
</template>
|
|
131
|
-
<template slot="controls"
|
|
139
|
+
<template slot="controls">
|
|
132
140
|
<controles-modal>
|
|
133
141
|
<button class="button1 btn-main" @click="pushElement()" title="Guardar entrada">Guardar</button>
|
|
134
142
|
</controles-modal>
|
package/apps/vueRela.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Vue.component("modal-relaciones",{props:["element","type"],data(){return{state:{modal:!1},info:{users:this.$parent.users,user:"",people:[]},content:{edit:JSON.parse(JSON.stringify(this.element)),current:this.element}}},computed:{modalTitle(){return"new"===this.type?"Nueva entrada":"edit"===this.type?"Editar entrada":void 0},oneCheck(){let e="";return Object.keys(this.content.edit).length?(this.content.edit.name.length<3&&(e+="<li>Escribe el nombre del personaje.</li>"),-1===this.content.edit.color&&(e+="<li>Selecciona una facción para el personaje.</li>"),-1===this.content.edit.url.indexOf("/u")&&(e+="<li>Escribe el enlace al perfil del personaje.</li>"),this.content.edit.img.match(/(jpg|jpeg|png)$/i)||(e+="<li>Escribe el enlace a la imagen del personaje (debe ser de 190x190).</li>"),this.content.edit.desc.length<151&&(e+="<li>Escribe una descripción lo suficientemente larga (150 carácteres al menos).</li>"),e):e},finalCheck(){return JSON.stringify(this.content.current)!==JSON.stringify(this.content.edit)},sortedCharacters(){return Object.keys(this.content.edit).length?this.info.users.filter(e=>-1===this.info.people.indexOf(e.user)).filter(e=>e.user.toLowerCase().indexOf(this.content.edit.name.toLowerCase())>-1):this.$parent.users.map(e=>e.user)}},methods:{modalClose(){this.$parent.modal.type="new",this.$parent.modal.status=!1,this.$parent.setEntry()},addCharacter(e){this.content.edit.type=!0,this.content.edit.name=e.user,this.content.edit.img=e.img,this.content.edit.color=e.color,this.content.edit.url=e.id},updateData(){const e=JSON.parse(JSON.stringify(this.info.users)).filter(e=>e.user===this.content.current.name)[0];this.content.edit.img=e.img},pushElement(){"edit"===this.$parent.modal.type&&this.$parent.content.edit.splice(this.$parent.content.edit.map(e=>e.position).indexOf(this.content.current.position),1);let e=this.content.edit;"new"===this.$parent.modal.type&&(e.position=this.$parent.content.edit.length),this.$parent.content.edit.push(e),this.modalClose()}},template:'\n <modal-foro :title="modalTitle" @modal-close="modalClose()">\n <template v-if="content.edit.type">\n <template slot="content">\n <aviso-foro v-show="oneCheck.length">\n <ul v-html="oneCheck"></ul>\n </aviso-foro>\n <ul class="forum-fieldlist no-style">\n <li>\n <campo-foro name="Nombre">\n <div class="character-selector">\n <input type="text" v-model="content.edit.name" placeholder="Escribe el nombre del personaje." disabled />\n <a class="character-custom" @click="updateData()" :title="\'Actualizar avatar de «\' + content.current.name + \'»\'">\n <i class="fas fa-redo-alt"></i>\n </a>\n </div>\n </campo-foro>\n </li>\n </ul>\n <h4 class="mt-5">Descripción</h4>\n <ul class="forum-fieldlist no-style">\n <li class="has-no-label">\n <campo-foro name="Descripción">\n <textarea v-model="content.edit.desc" placeholder="Escribe la descripción del personaje."></textarea>\n </campo-foro>\n </li>\n </ul>\n </template>\n <template slot="controls" v-if="!oneCheck.length && finalCheck">\n <controles-modal>\n <button class="button1 btn-main" @click="pushElement()" title="Guardar entrada">Guardar</button>\n </controles-modal>\n </template>\n </template>\n <template v-else>\n <template slot="content">\n <aviso-foro v-show="oneCheck.length">\n <ul v-html="oneCheck"></ul>\n </aviso-foro>\n <ul class="forum-fieldlist no-style">\n <li>\n <campo-foro name="Nombre">\n <div class="character-selector"> \n <input type="text" v-model="content.edit.name" placeholder="Escribe el nombre del personaje." />\n <ul class="no-style selector-list" v-if="sortedCharacters.length > 0">\n <li v-for="(character, index) in sortedCharacters" @click="addCharacter(character)" :title="\'Seleccionar \' + character.user">{{ character.user }}<i class="fas fa-plus"></i></li>\n </ul>\n </div>\n </campo-foro>\n </li>\n <li>\n <campo-foro name="Imagen">\n <input type="text" v-model="content.edit.img" placeholder="Escribe el enlace a la imagen del personaje." />\n </campo-foro>\n </li>\n <li>\n <campo-foro name="Perfil">\n <input type="text" v-model="content.edit.url" placeholder="Escribe el enlace al perfil del personaje." />\n </campo-foro>\n </li>\n <li>\n <campo-foro name="Facción">\n <div class="select-container">\n <select v-model="content.edit.color">\n <option value="-1" hidden>Selecciona la facción del personaje.</option>\n <option value="azul">Imperio Galáctico</option>\n <option value="rojo">Remanente Purista</option>\n <option value="naranja">Autoridad del Sector Corporativo</option>\n <option value="verde">Cártel</option>\n <option value="turquesa">Nueva Rebelión</option>\n <option value="amarillo">Neutral</option>\n </select>\n </div>\n </campo-foro>\n </li>\n </ul>\n <h4 class="mt-5">Descripción</h4>\n <ul class="forum-fieldlist no-style">\n <li class="has-no-label">\n <campo-foro name="Descripción">\n <textarea v-model="content.edit.desc" placeholder="Escribe la descripción del personaje."></textarea>\n </campo-foro>\n </li>\n </ul>\n </template>\n <template slot="controls" v-if="!oneCheck.length && finalCheck">\n <controles-modal>\n <button class="button1 btn-main" @click="pushElement()" title="Guardar entrada">Guardar</button>\n </controles-modal>\n </template>\n </template>\n </modal-foro>\n '}),Vue.component("gestor-relaciones",{data:()=>({render:0,modal:{type:"new",status:!1},users:[],state:{page:0,pagination:0},entry:{},content:{edit:[],current:[]}}),computed:{sortedContent(){return JSON.parse(JSON.stringify(this.content.edit)).sort((e,t)=>e.name<t.name?-1:e.name>t.name?1:0)},paginationContent(){const e=parseInt(forumConfig.skinOptions.paginationDefault/2)+1,t=Math.floor((this.sortedContent.length-1)/e)+1;let n=[];for(let e=0;e<t;e++)n.push(e);return this.forceRerender(),{pages:n,content:this.sortedContent.slice(this.state.pagination*e,(this.state.pagination+1)*e)}},finalCheck(){return JSON.stringify(this.content.current)!==JSON.stringify(this.content.edit)}},methods:{forceRerender(){this.render+=1},setEntry(){this.entry={type:!1,color:-1,url:"",img:"",name:"",desc:""}},addEntry(e){e.preventDefault(),this.modal.status=!0},save(e){e.preventDefault(),this.state.page=2;const t=this.sortedContent.map(e=>(void 0!==e.position&&delete e.position,e));FNR.user.profile.setData([{name:forumConfig.profileUser.relaField,type:"textarea",value:JSON.stringify(t).replace(/"/g,"`")}]).then(e=>{e?(FNR.html.genNotification("Atención","Información actualizada sin inconvenientes.","fas fa-check"),setTimeout(()=>{window.location.reload()},2e3)):FNR.html.genNotification("Atención","Hubo un problema al actualizar. Dale otro intento.","fas fa-exclamation")})}},created(){FNR.user.profile.getData([{name:forumConfig.profileUser.relaField,type:"textarea"}]).then(e=>{const t=FNR.utility.genArray(e[0].value).map((e,t)=>{let n=e;return n.position=t,n});this.content.edit=t,this.content.current=JSON.parse(JSON.stringify(t)),FNR.forum.getMembers().then(e=>{this.setEntry(),this.users=e,this.state.page=1})})},template:'\n <section id="forum-relationships" class="wiki-content is-dramatic">\n <div class="is-content">\n <h2>Relaciones</h2>\n <hr />\n <p>En esta página podrás editar las relaciones de tu personaje.</p>\n <p>Ante cualquier duda o problema, contacta con la administración.</p>\n </div>\n <separador-foro />\n <template v-if="state.page === 0">\n <cargando-foro text="Cargando utilidad…"></cargando-foro>\n </template>\n <template v-else-if="state.page === 1">\n <modal-relaciones v-if="modal.status" :type="modal.type" :element="entry"></modal-relaciones>\n <mando-foro id="upper-controls" app="true">\n <template slot="pagination" v-if="paginationContent.pages.length > 1">\n <a class="page-action" title="Ir a la página anterior" v-if="state.pagination > 0" @click="state.pagination -= 1">\n <i class="fas fa-chevron-left"></i>\n </a>\n <template v-for="page in paginationContent.pages">\n <strong v-if="page === state.pagination">{{ page + 1 }}</strong>\n <a class="page-link" :title="\'Ir a la página «\' + (page + 1) + \'»\'" v-else @click="state.pagination = page">{{ page + 1 }}</a>\n </template>\n <a class="page-action" title="Ir a la página siguiente" v-if="(state.pagination + 1) < paginationContent.pages.length" @click="state.pagination += 1">\n <i class="fas fa-chevron-right"></i>\n </a>\n </template>\n <template slot="controls">\n <li @click="addEntry($event)">\n <boton-foro url="#" name="Añadir" icon="fas fa-plus"></boton-foro>\n </li>\n <li v-if="finalCheck" @click="save($event)">\n <boton-foro url="#" name="Guardar" icon="fas fa-save" type="no-name"></boton-foro>\n </li>\n </template>\n </mando-foro>\n <section id="forum-rplist" class="forum-wikilist">\n <lista-temas-cabecera elements="[\'Personajes\', \'Información\']"></lista-temas-cabecera>\n <ul :class="\'wikilist-contents no-style\' + (!paginationContent.content.length ? \' no-results\': \'\')" :key="render">\n <template v-if="!paginationContent.content.length">\n <li class="is-not-topic is-not-lastpost">\n <h6>No hay entradas en tus relaciones</h6>\n </li>\n </template>\n <template v-else v-for="character in paginationContent.content">\n <elemento-relaciones :element="character" type="manager" :id="character.position" />\n </template>\n </ul>\n </section>\n <mando-foro id="lower-controls" app="true">\n <template slot="pagination" v-if="paginationContent.pages.length > 1">\n <a class="page-action" title="Ir a la página anterior" v-if="state.pagination > 0" @click="state.pagination -= 1">\n <i class="fas fa-chevron-left"></i>\n </a>\n <template v-for="page in paginationContent.pages">\n <strong v-if="page === state.pagination">{{ page + 1 }}</strong>\n <a class="page-link" :title="\'Ir a la página «\' + (page + 1) + \'»\'" v-else @click="state.pagination = page">{{ page + 1 }}</a>\n </template>\n <a class="page-action" title="Ir a la página siguiente" v-if="(state.pagination + 1) < paginationContent.pages.length" @click="state.pagination += 1">\n <i class="fas fa-chevron-right"></i>\n </a>\n </template>\n <template slot="controls">\n <li @click="addEntry($event)">\n <boton-foro url="#" name="Añadir" icon="fas fa-plus"></boton-foro>\n </li>\n <li v-if="finalCheck" @click="save($event)">\n <boton-foro url="#" name="Guardar" icon="fas fa-save" type="no-name"></boton-foro>\n </li>\n </template>\n </mando-foro>\n </template>\n <template v-else-if="state.page === 2">\n <cargando-foro text="Actualizando información…"></cargando-foro>\n </template>\n </section>\n '}),Vue.component("elemento-relaciones",{props:["element","type","id"],data(){return{profileName:forumConfig.profileOptions.profileName||"perfil",content:this.element}},computed:{realClass(){return"rela-list usergroup-"+this.content.color}},methods:{deleteElement(){this.$parent.content.edit.splice(this.$parent.content.edit.map(e=>e.position).indexOf(this.id),1),0===this.$parent.paginationContent.content.length&&0!==this.$parent.state.pagination&&(this.$parent.state.pagination-=1),this.$parent.forceRerender()},editElement(){this.$parent.modal.type="edit",this.$parent.entry=this.content,this.$parent.modal.status=!0}},template:'\n <li :class="realClass">\n <template v-if="type === \'manager\'">\n <a class="rela-element rela-manager">\n <div class="rela-image" :style="\'background-image: url(\' + content.img + \')\'"></div>\n <div class="rela-content">\n <div class="rela-title">\n <h4>{{ content.name }}</h4>\n <div class="rp-controls"><span @click="editElement()" title="Editar entrada">Editar</span> / <span @click="deleteElement()" title="Eliminar entrada">Eliminar</span></div>\n </div>\n <div class="small-text is-content" :inner-html.prop="content.desc | turn-br"></div>\n </div>\n </a>\n </template>\n <template v-else-if="type === \'profile\'">\n <template v-if="content.type">\n <a class="rela-element" :href="content.url" target="_blank" :title="\'Ir al \' + profileName + \' de «\' + content.name + \'»\'">\n <div class="rela-image" :style="\'background-image: url(\' + content.img + \')\'"></div>\n <div class="rela-content">\n <div class="rela-title">\n <h4>{{ content.name }}</h4>\n </div>\n <div class="small-text is-content" :inner-html.prop="content.desc | turn-br"></div>\n </div>\n </a>\n </template>\n <template v-else>\n <a class="rela-element">\n <div class="rela-image" :style="\'background-image: url(\' + content.img + \')\'"></div>\n <div class="rela-content">\n <div class="rela-title">\n <h4>{{ content.name }}</h4>\n </div>\n <div class="small-text is-content" :inner-html.prop="content.desc | turn-br"></div>\n </div>\n </a>\n </template>\n </template>\n </li>\n '});
|
|
1
|
+
Vue.component("modal-relaciones",{props:["element","type"],data(){return{state:{modal:!1},info:{users:this.$parent.users,user:"",people:[]},content:{edit:JSON.parse(JSON.stringify(this.element)),current:this.element}}},computed:{modalTitle(){return"new"===this.type?"Nueva entrada":"edit"===this.type?"Editar entrada":void 0},oneCheck(){let e="";return Object.keys(this.content.edit).length?(this.content.edit.name.length<3&&(e+="<li>Escribe el nombre del personaje.</li>"),-1===this.content.edit.color&&(e+="<li>Selecciona una facción para el personaje.</li>"),-1===this.content.edit.url.indexOf("/u")&&(e+="<li>Escribe el enlace al perfil del personaje.</li>"),this.content.edit.img.match(/(jpg|jpeg|png)$/i)||(e+="<li>Escribe el enlace a la imagen del personaje (debe ser de 190x190).</li>"),this.content.edit.desc.length<151&&(e+="<li>Escribe una descripción lo suficientemente larga (150 carácteres al menos).</li>"),e):e},finalCheck(){return JSON.stringify(this.content.current)!==JSON.stringify(this.content.edit)},sortedCharacters(){return Object.keys(this.content.edit).length?this.info.users.filter(e=>-1===this.info.people.indexOf(e.user)).filter(e=>e.user.toLowerCase().indexOf(this.content.edit.name.toLowerCase())>-1):this.$parent.users.map(e=>e.user)}},methods:{modalClose(){this.$parent.modal.type="new",this.$parent.modal.status=!1,this.$parent.setEntry()},addCharacter(e){this.content.edit.type=!0,this.content.edit.name=e.user,this.content.edit.img=e.img,this.content.edit.color=e.color,this.content.edit.url=e.id},updateData(){const e=JSON.parse(JSON.stringify(this.info.users)).filter(e=>e.user===this.content.current.name)[0];this.content.edit.img=e.img},pushElement(){if(!this.oneCheck.length)return;this.finalCheck&&this.modalClose(),"edit"===this.$parent.modal.type&&this.$parent.content.edit.splice(this.$parent.content.edit.map(e=>e.position).indexOf(this.content.current.position),1);let e=this.content.edit;"new"===this.$parent.modal.type&&(e.position=this.$parent.content.edit.length),this.$parent.content.edit.push(e),this.modalClose()}},template:'\n <modal-foro :title="modalTitle" @modal-close="modalClose()">\n <template v-if="content.edit.type">\n <template slot="content">\n <aviso-foro v-show="oneCheck.length">\n <ul v-html="oneCheck"></ul>\n </aviso-foro>\n <ul class="forum-fieldlist no-style">\n <li>\n <campo-foro name="Nombre">\n <div class="character-selector">\n <input type="text" v-model="content.edit.name" placeholder="Escribe el nombre del personaje." disabled />\n <a class="character-custom" @click="updateData()" :title="\'Actualizar avatar de «\' + content.current.name + \'»\'">\n <i class="fas fa-redo-alt"></i>\n </a>\n </div>\n </campo-foro>\n </li>\n </ul>\n <h4 class="mt-5">Descripción</h4>\n <ul class="forum-fieldlist no-style">\n <li class="has-no-label">\n <campo-foro name="Descripción">\n <textarea v-model="content.edit.desc" placeholder="Escribe la descripción del personaje."></textarea>\n </campo-foro>\n </li>\n </ul>\n </template>\n <template slot="controls">\n <controles-modal>\n <button class="button1 btn-main" @click="pushElement()" title="Guardar entrada">Guardar</button>\n </controles-modal>\n </template>\n </template>\n <template v-else>\n <template slot="content">\n <aviso-foro v-show="oneCheck.length">\n <ul v-html="oneCheck"></ul>\n </aviso-foro>\n <ul class="forum-fieldlist no-style">\n <li>\n <campo-foro name="Nombre">\n <div class="character-selector"> \n <input type="text" v-model="content.edit.name" placeholder="Escribe el nombre del personaje." />\n <ul class="no-style selector-list" v-if="sortedCharacters.length > 0">\n <li v-for="(character, index) in sortedCharacters" @click="addCharacter(character)" :title="\'Seleccionar \' + character.user">{{ character.user }}<i class="fas fa-plus"></i></li>\n </ul>\n </div>\n </campo-foro>\n </li>\n <li>\n <campo-foro name="Imagen">\n <input type="text" v-model="content.edit.img" placeholder="Escribe el enlace a la imagen del personaje." />\n </campo-foro>\n </li>\n <li>\n <campo-foro name="Perfil">\n <input type="text" v-model="content.edit.url" placeholder="Escribe el enlace al perfil del personaje." />\n </campo-foro>\n </li>\n <li>\n <campo-foro name="Facción">\n <div class="select-container">\n <select v-model="content.edit.color">\n <option value="-1" hidden>Selecciona la facción del personaje.</option>\n <option value="azul">Imperio Galáctico</option>\n <option value="rojo">Remanente Purista</option>\n <option value="naranja">Autoridad del Sector Corporativo</option>\n <option value="verde">Cártel</option>\n <option value="turquesa">Nueva Rebelión</option>\n <option value="amarillo">Neutral</option>\n </select>\n </div>\n </campo-foro>\n </li>\n </ul>\n <h4 class="mt-5">Descripción</h4>\n <ul class="forum-fieldlist no-style">\n <li class="has-no-label">\n <campo-foro name="Descripción">\n <textarea v-model="content.edit.desc" placeholder="Escribe la descripción del personaje."></textarea>\n </campo-foro>\n </li>\n </ul>\n </template>\n <template slot="controls" v-if="!oneCheck.length && finalCheck">\n <controles-modal>\n <button class="button1 btn-main" @click="pushElement()" title="Guardar entrada">Guardar</button>\n </controles-modal>\n </template>\n </template>\n </modal-foro>\n '}),Vue.component("gestor-relaciones",{data:()=>({render:0,modal:{type:"new",status:!1},users:[],state:{page:0,pagination:0},entry:{},content:{edit:[],current:[]}}),computed:{sortedContent(){return JSON.parse(JSON.stringify(this.content.edit)).sort((e,t)=>e.name<t.name?-1:e.name>t.name?1:0)},paginationContent(){const e=parseInt(forumConfig.skinOptions.paginationDefault/2)+1,t=Math.floor((this.sortedContent.length-1)/e)+1;let n=[];for(let e=0;e<t;e++)n.push(e);return this.forceRerender(),{pages:n,content:this.sortedContent.slice(this.state.pagination*e,(this.state.pagination+1)*e)}},finalCheck(){return JSON.stringify(this.content.current)!==JSON.stringify(this.content.edit)}},methods:{forceRerender(){this.render+=1},setEntry(){this.entry={type:!1,color:-1,url:"",img:"",name:"",desc:""}},addEntry(e){e.preventDefault(),this.modal.status=!0},save(e){e.preventDefault(),this.state.page=2;const t=this.sortedContent.map(e=>(void 0!==e.position&&delete e.position,e));FNR.user.profile.setData([{name:forumConfig.profileUser.relaField,type:"textarea",value:JSON.stringify(t).replace(/"/g,"`")}]).then(e=>{e?(FNR.html.genNotification("Atención","Información actualizada sin inconvenientes.","fas fa-check"),setTimeout(()=>{window.location.reload()},2e3)):FNR.html.genNotification("Atención","Hubo un problema al actualizar. Dale otro intento.","fas fa-exclamation")})}},created(){FNR.user.profile.getData([{name:forumConfig.profileUser.relaField,type:"textarea"}]).then(e=>{const t=FNR.utility.genArray(e[0].value).map((e,t)=>{let n=e;return n.position=t,n});this.content.edit=t,this.content.current=JSON.parse(JSON.stringify(t)),FNR.forum.getMembers().then(e=>{this.setEntry(),this.users=e,this.state.page=1})})},template:'\n <section id="forum-relationships" class="wiki-content is-dramatic">\n <div class="is-content">\n <h2>Relaciones</h2>\n <hr />\n <p>En esta página podrás editar las relaciones de tu personaje.</p>\n <p>Ante cualquier duda o problema, contacta con la administración.</p>\n </div>\n <separador-foro />\n <template v-if="state.page === 0">\n <cargando-foro text="Cargando utilidad…"></cargando-foro>\n </template>\n <template v-else-if="state.page === 1">\n <modal-relaciones v-if="modal.status" :type="modal.type" :element="entry"></modal-relaciones>\n <mando-foro id="upper-controls" app="true">\n <template slot="pagination" v-if="paginationContent.pages.length > 1">\n <a class="page-action" title="Ir a la página anterior" v-if="state.pagination > 0" @click="state.pagination -= 1">\n <i class="fas fa-chevron-left"></i>\n </a>\n <template v-for="page in paginationContent.pages">\n <strong v-if="page === state.pagination">{{ page + 1 }}</strong>\n <a class="page-link" :title="\'Ir a la página «\' + (page + 1) + \'»\'" v-else @click="state.pagination = page">{{ page + 1 }}</a>\n </template>\n <a class="page-action" title="Ir a la página siguiente" v-if="(state.pagination + 1) < paginationContent.pages.length" @click="state.pagination += 1">\n <i class="fas fa-chevron-right"></i>\n </a>\n </template>\n <template slot="controls">\n <li @click="addEntry($event)">\n <boton-foro url="#" name="Añadir" icon="fas fa-plus"></boton-foro>\n </li>\n <li v-if="finalCheck" @click="save($event)">\n <boton-foro url="#" name="Guardar" icon="fas fa-save" type="no-name"></boton-foro>\n </li>\n </template>\n </mando-foro>\n <section id="forum-rplist" class="forum-wikilist">\n <lista-temas-cabecera elements="[\'Personajes\', \'Información\']"></lista-temas-cabecera>\n <ul :class="\'wikilist-contents no-style\' + (!paginationContent.content.length ? \' no-results\': \'\')" :key="render">\n <template v-if="!paginationContent.content.length">\n <li class="is-not-topic is-not-lastpost">\n <h6>No hay entradas en tus relaciones</h6>\n </li>\n </template>\n <template v-else v-for="character in paginationContent.content">\n <elemento-relaciones :element="character" type="manager" :id="character.position" />\n </template>\n </ul>\n </section>\n <mando-foro id="lower-controls" app="true">\n <template slot="pagination" v-if="paginationContent.pages.length > 1">\n <a class="page-action" title="Ir a la página anterior" v-if="state.pagination > 0" @click="state.pagination -= 1">\n <i class="fas fa-chevron-left"></i>\n </a>\n <template v-for="page in paginationContent.pages">\n <strong v-if="page === state.pagination">{{ page + 1 }}</strong>\n <a class="page-link" :title="\'Ir a la página «\' + (page + 1) + \'»\'" v-else @click="state.pagination = page">{{ page + 1 }}</a>\n </template>\n <a class="page-action" title="Ir a la página siguiente" v-if="(state.pagination + 1) < paginationContent.pages.length" @click="state.pagination += 1">\n <i class="fas fa-chevron-right"></i>\n </a>\n </template>\n <template slot="controls">\n <li @click="addEntry($event)">\n <boton-foro url="#" name="Añadir" icon="fas fa-plus"></boton-foro>\n </li>\n <li v-if="finalCheck" @click="save($event)">\n <boton-foro url="#" name="Guardar" icon="fas fa-save" type="no-name"></boton-foro>\n </li>\n </template>\n </mando-foro>\n </template>\n <template v-else-if="state.page === 2">\n <cargando-foro text="Actualizando información…"></cargando-foro>\n </template>\n </section>\n '}),Vue.component("elemento-relaciones",{props:["element","type","id"],data(){return{profileName:forumConfig.profileOptions.profileName||"perfil",content:this.element}},computed:{realClass(){return"rela-list usergroup-"+this.content.color}},methods:{deleteElement(){this.$parent.content.edit.splice(this.$parent.content.edit.map(e=>e.position).indexOf(this.id),1),0===this.$parent.paginationContent.content.length&&0!==this.$parent.state.pagination&&(this.$parent.state.pagination-=1),this.$parent.forceRerender()},editElement(){this.$parent.modal.type="edit",this.$parent.entry=this.content,this.$parent.modal.status=!0}},template:'\n <li :class="realClass">\n <template v-if="type === \'manager\'">\n <a class="rela-element rela-manager">\n <div class="rela-image" :style="\'background-image: url(\' + content.img + \')\'"></div>\n <div class="rela-content">\n <div class="rela-title">\n <h4>{{ content.name }}</h4>\n <div class="rp-controls"><span @click="editElement()" title="Editar entrada">Editar</span> / <span @click="deleteElement()" title="Eliminar entrada">Eliminar</span></div>\n </div>\n <div class="small-text is-content" :inner-html.prop="content.desc | turn-br"></div>\n </div>\n </a>\n </template>\n <template v-else-if="type === \'profile\'">\n <template v-if="content.type">\n <a class="rela-element" :href="content.url" target="_blank" :title="\'Ir al \' + profileName + \' de «\' + content.name + \'»\'">\n <div class="rela-image" :style="\'background-image: url(\' + content.img + \')\'"></div>\n <div class="rela-content">\n <div class="rela-title">\n <h4>{{ content.name }}</h4>\n </div>\n <div class="small-text is-content" :inner-html.prop="content.desc | turn-br"></div>\n </div>\n </a>\n </template>\n <template v-else>\n <a class="rela-element">\n <div class="rela-image" :style="\'background-image: url(\' + content.img + \')\'"></div>\n <div class="rela-content">\n <div class="rela-title">\n <h4>{{ content.name }}</h4>\n </div>\n <div class="small-text is-content" :inner-html.prop="content.desc | turn-br"></div>\n </div>\n </a>\n </template>\n </template>\n </li>\n '});
|