index.vue 7.99 KB
Newer Older
Esteban Choque's avatar
Esteban Choque committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<template>
  <section
    class="container page">

    <div
      v-for="topic in forum.topics"
      :key="topic.id_topic">

      <div class="page-header">
        <div
          class="page-img-main"
          :style="{ 'background-image': `url(`+forum.img_dest+`)` }">
        </div>
        <div 
          class="page-title">
          <h1 v-html="topic.name"></h1>
          <div class="page-title-details">
            <nuxt-link
              :to="$i18n.path(`participa/`)">
              Participa
            </nuxt-link> /
            <nuxt-link
              :to="$i18n.path(`participa/`+$route.params.id_forum+`/`+$route.params.name_forum)">
              {{ forum.name }}
            </nuxt-link>
          </div>
        </div>
      </div>

      <div
        v-for="topic in forum.topics"
        :key="topic.id_topic"
        class="page-content">
        <p v-html="topic.desc"></p>
        <h3 class="subtitle">
          Debates
        </h3>
        <div
          v-for="post in topic.posts"
          :key="post.id_forum">
          <nuxt-link
            :to="$i18n.path(`participa/`+$route.params.id_forum+`/`+$route.params.name_forum+`/`+$route.params.id_topic+`/`+$route.params.name_topic+`/`+post.id_post+`/`+post.slug)">
43
            <p>{{ post.title }}</p>
Esteban Choque's avatar
Esteban Choque committed
44
          </nuxt-link>
45
          <p class="info_post">{{ post.nombre }}</p>
Esteban Choque's avatar
Esteban Choque committed
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
          <p>{{ post.extract_body }}</p>
          <hr class="separador_post">
        </div>
        <el-row 
          type="flex"
          class="row-bg"
          justify="center">
          <el-pagination
            small
            :total="page_num_posts"
            :page-size="10"
            :pager-count="3"
            layout="prev, pager, next"
            @current-change="pagina">
          </el-pagination>
        </el-row>
        
        <h3 class="subtitle">
          Inicia un nuevo Debate:
        </h3>
66
        <p class="tu_info">Tu Información:</p>
Esteban Choque's avatar
Esteban Choque committed
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
        <span class="demo-input-label">Nombre:</span>
        <el-input 
          placeholder="Escribe tu nombre"
          v-model="nombre"></el-input>
        <span class="demo-input-label">Email (no será publicado)(requerido):</span>
        <el-input 
          placeholder="Escribe tu correo"
          v-model="correo"></el-input>
        <span class="demo-input-label">Título del debate (Longitud máxima: 80):</span>
        <el-input 
          placeholder="Escribe un título para el debate"
          v-model="titulo"></el-input>
        <span class="demo-input-label">Contenido del debate:</span>
        <el-input
          type="textarea"
          :autosize="{ minRows: 4, maxRows: 8}"
          placeholder="Escribe el contenido para el debate"
          v-model="contenido">
        </el-input>
        <el-row 
          type="flex"
          class="row-bg"
          justify="center">
          <el-button
            @click="sendPublicacion"
            type="info"
            class="btn_nuevo_debate">Enviar</el-button>
        </el-row>
      </div>

    </div>
  </section>
</template>

<script>
import axios from 'axios';
export default {
  head () {
    return {
      title: this.page_tit
    };
  },
  data() {
    return {
      forum: [],
      replies: [],
      id_publicacion:'',
      nombre: '',
      correo: '',
      titulo: '',
      contenido: '',
      page_tit: '',
      page_num_posts: ''
    };
  },
  mounted () {
    this.$store.commit('CLOSE_MENU');
    this.$util.setBackgroundImage();
    this.pagina(1);
  },
  methods: {
    getTopics() {
     axios.get('http://localhost/wordpress/index.php?rest_route=/topic_posts/v1/'+this.$route.params.id_forum+'/'+this.$route.params.id_topic)
      .then(response => {
        this.forum = response.data[this.$route.params.id_forum];
        this.page_tit = this.forum.topics[this.$route.params.id_topic].name;
        console.log(response.status); // ex.: 200
     }); 
    },
    sendPublicacion() {
      this.params = {
        id_topic: this.$route.params.id_topic,
        nombre: this.nombre,
        correo: this.correo,
        post_title: this.titulo,
        the_content: this.contenido
      };
      console.log('nombre '+this.nombre);
      console.log('correo '+this.correo);
      console.log('post_title '+this.titulo);
      console.log('the_content '+this.contenido);
      if(this.nombre == '' && this.correo == '' && this.titulo == '' && this.contenido == '')
      {
        console.log('Falta nombre');
        console.log('Falta correo');
        console.log('Falta titulo');
        console.log('Falta contenido');
      }
      else if(this.correo == '' && this.titulo == '' && this.contenido == '')
      {
        console.log('Falta nombre');
      }
      else if(this.nombre == '' && this.titulo == '' && this.contenido == '')
      {
        console.log('Falta correo');
      }
      else if(this.nombre == '' && this.correo == '' && this.contenido == '')
      {
        console.log('Falta titulo');
      }
      else if(this.nombre == '' && this.correo == '' && this.titulo == '')
      {
        console.log('Falta contenido');
      }
      else if(this.titulo == '' && this.contenido == '')
      {
        console.log('Falta nombre');
        console.log('Falta correo');
      }
      else if(this.nombre == '' && this.contenido == '')
      {
        console.log('Falta correo');
        console.log('Falta titulo');
      }
      else if(this.nombre == '' && this.correo == '')
      {
        console.log('Falta titulo');
        console.log('Falta contenido');
      }
      else if(this.nombre == '')
      {
        console.log('Falta correo');
        console.log('Falta titulo');
        console.log('Falta contenido');
      }
      else if(this.correo == '')
      {
        console.log('Falta nombre');
        console.log('Falta titulo');
        console.log('Falta contenido');
      }
      else if(this.titulo == '')
      {
        console.log('Falta nombre');
        console.log('Falta correo');
        console.log('Falta contenido');
      }
      else if(this.contenido == '')
      {
        console.log('Falta nombre');
        console.log('Falta correo');
        console.log('Falta titulo');
      }
      
     
      axios.post('http://localhost/wordpress/index.php?rest_route=/addPublicacion/v1/', this.params)
      .then(response => {
        console.log(response.status); // ex.: 200
        this.pagina(1);
        this.nombre = "";
        this.correo = "";
        this.titulo = "";
        this.contenido = "";
     });
    },
    pagina (start) {
      axios.get('http://localhost/wordpress/index.php?rest_route=/paginador/v1/'+this.$route.params.id_forum+'/'+this.$route.params.id_topic+'/start='+((start-1)*10))
      .then(response => {
        this.forum = response.data[this.$route.params.id_forum];
        this.page_num_posts = parseInt(this.forum.topics[this.$route.params.id_topic].num_posts);
        console.log(response.status); // ex.: 200
     }); 
    },
    validarNombre () {
      console.log('ffs');
      if(this.nombre == '')
      {
        console.log('vacio');
      }
      else
      {
        console.log('hay algo');
      }
    }
  }
};
</script>


<style lang="scss" src="./page.scss"></style>
<style lang="scss">
.topic
{
  background-image: url("/_nuxt/src/assets/images/resources/bg-blue.svg");
  background-size: cover;
  padding-left: 25px;
  padding-top: 5px;
  padding-bottom: 5px;
  color:#fff;
}
.demo-input-label {
    display: inline-block;
    /*width: 130px;*/
  }
.btn_nuevo_debate
{
  margin-top:20px;
}
.separador_post
{
  display: block !important;
  margin-top: 0.5em !important;
  margin-bottom: 0.5em !important;
  margin-left: auto !important;
  margin-right: auto !important;
  border-style: inset !important;
  border-width: 1px !important;
  border-top: 1px solid #e8e8e8 !important;
}
.subtitle
{
  background: #024f9b;
  color:#fff;
  margin-left: -25px;
  margin-right: -25px;
  padding-top: 15px;
  padding-right: 25px;
  padding-bottom: 15px;
  padding-left: 25px;
  text-align: left;
}
288
289
290
291
292
293
294
295
296
297
.info_post
{
  font-style: italic;
  color: #333333;
  font-size: 1.0rem;
}
.tu_info
{
  font-weight: bold;
}
Esteban Choque's avatar
Esteban Choque committed
298
</style>