Blame view

src/pages/Annoucement/annoucementForum.vue 10.8 KB
640ed7acb   Neeraj Sharma   implement annouce...
1
2
3
4
5
  <template>
    <v-container fluid class="body-color">
      <!-- ******ANNOUCEMNET DISCUSSION COMMENT ****** -->
      <v-layout>
        <v-flex xs12 v-for="(annoucementData,i) in annoucementData" :key="i">
8ac91bfcd   Amber Dev   added changes to ...
6
          <!-- TOPIC HEADING -->
640ed7acb   Neeraj Sharma   implement annouce...
7
8
9
10
11
12
13
14
15
16
17
          <v-card class="elevation-0 grey lighten-3 pa-2" flat>
            <v-list two-line subheader>
              <v-list-tile>
                <v-list-tile-avatar>
                  <v-avatar size="46">
                    <img :src="annoucementData.attachementUrl" v-if="annoucementData.attachementUrl" />
                    <img src="/static/icon/user.png" v-else-if="!annoucementData.attachementUrl" />
                  </v-avatar>
                </v-list-tile-avatar>
                <v-list-tile-content>
                  <v-list-tile-title>{{ annoucementData.discussionType }}</v-list-tile-title>
3311ad345   Neeraj Sharma   add event list in...
18
                  <v-list-tile-sub-title>
640ed7acb   Neeraj Sharma   implement annouce...
19
                    By
8ac91bfcd   Amber Dev   added changes to ...
20
21
22
23
24
25
26
27
                    <span
                      class="info--text"
                      v-if="annoucementData.studentId"
                    >{{ annoucementData.studentId.name }}</span>
                    <span
                      class="info--text"
                      v-if="annoucementData.teacherId"
                    >{{ annoucementData.teacherId.name }}</span>
640ed7acb   Neeraj Sharma   implement annouce...
28
                    - {{dates(annoucementData.created ) }}
3311ad345   Neeraj Sharma   add event list in...
29
                  </v-list-tile-sub-title>
640ed7acb   Neeraj Sharma   implement annouce...
30
31
32
33
34
35
36
37
38
                </v-list-tile-content>
                <v-list-tile-action>
                  <div>
                    <v-btn flat round dark class="reply-btn" @click="showReplyBox = true">Reply</v-btn>
                  </div>
                </v-list-tile-action>
              </v-list-tile>
            </v-list>
          </v-card>
8ac91bfcd   Amber Dev   added changes to ...
39
          <!-- REPLY BOX -->
640ed7acb   Neeraj Sharma   implement annouce...
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
          <v-flex xs12 class="mt-4" v-show="showReplyBox">
            <v-textarea
              name="input-7-1"
              solo
              label="Label Text"
              multi-line
              v-model="replyDescription"
            ></v-textarea>
            <v-btn round dark class="open-dialog-button" flat @click="showReplyBox = false">Cancel</v-btn>
            <v-btn
              round
              dark
              :loading="loading"
              class="reply-btn"
              @click="replyThreadDiscussion()"
            >Submit</v-btn>
          </v-flex>
8ac91bfcd   Amber Dev   added changes to ...
57
58
59
60
61
  
          <!-- REPLY THREAD -->
          <v-layout
            :class="['mt-4','pl-5','mx-auto',replyThread.teacherId?'justify-start':'justify-end']"
            v-for="(replyThread,i) in annoucementData.discussionThread.slice().reverse()"
640ed7acb   Neeraj Sharma   implement annouce...
62
63
            :key="i"
          >
8ac91bfcd   Amber Dev   added changes to ...
64
65
66
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
            <v-flex xs12 md7>
              <v-card class="elevation-0 grey lighten-1" flat>
                <v-list two-line subheader class="grey lighten-1 pa-1">
                  <v-list-tile>
                    <v-list-tile-avatar>
                      <v-avatar size="46">
                        <img
                          :src="annoucementData.attachementUrl"
                          v-if="annoucementData.attachementUrl"
                        />
                        <img src="/static/icon/user.png" v-else-if="!annoucementData.attachementUrl" />
                      </v-avatar>
                    </v-list-tile-avatar>
                    <v-list-tile-content>
                      <v-list-tile-title>Re: {{ annoucementData.discussionType }}</v-list-tile-title>
                      <v-list-tile-sub-title>
                        By
                        <span
                          class="info--text"
                          v-if="replyThread.teacherId"
                        >{{ replyThread.teacherId.name }}</span>
                        <span
                          class="info--text"
                          v-if="replyThread.studentId"
                        >{{ replyThread.studentId.name }}</span>
                        - {{dates(replyThread.created ) }}
                      </v-list-tile-sub-title>
                    </v-list-tile-content>
                  </v-list-tile>
                </v-list>
                <v-list class="pa-2 reply-desc">
640ed7acb   Neeraj Sharma   implement annouce...
95
                  <v-list-tile-content>
8ac91bfcd   Amber Dev   added changes to ...
96
97
98
99
100
101
102
103
104
105
106
107
108
                    <v-list-tile-title
                      v-show="replyThread.showDescriptionReplyThread"
                    >{{ replyThread.description }}</v-list-tile-title>
                    <v-flex xs12 sm12 md4 v-show="replyThread.showUpdateReplyThread == true">
                      <v-text-field v-model="replyThread.description"></v-text-field>
                      <v-btn
                        flat
                        round
                        dark
                        class="reply-btn right"
                        @click="updateRelpyThreadDiscussion(replyThread)"
                      >Save</v-btn>
                    </v-flex>
640ed7acb   Neeraj Sharma   implement annouce...
109
                  </v-list-tile-content>
8ac91bfcd   Amber Dev   added changes to ...
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
                </v-list>
                <v-list class="grey lighten-4 pa-0">
                  <v-list-tile-action>
                    <v-spacer></v-spacer>
                    <div v-if="replyThread.teacherId && replyThread.teacherId._id == $store.state.id">
                      <v-btn
                        flat
                        round
                        dark
                        class="reply-btn"
                        @click="deleteRelpyThreadDiscussion(replyThread._id)"
                      >Delete</v-btn>
                      <v-btn
                        flat
                        round
                        dark
                        class="reply-btn mr-4"
                        @click="showUpdateReplyThreadDiscussion(replyThread)"
                      >Edit</v-btn>
                    </div>
                  </v-list-tile-action>
                </v-list>
              </v-card>
            </v-flex>
          </v-layout>
640ed7acb   Neeraj Sharma   implement annouce...
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
        </v-flex>
      </v-layout>
      <v-snackbar
        :timeout="timeout"
        :top="y === 'top'"
        :right="x === 'right'"
        :vertical="mode === 'vertical'"
        v-model="snackbar"
        color="success"
      >{{ text }}</v-snackbar>
      <div class="loader" v-if="showLoader">
        <v-progress-circular indeterminate color="white"></v-progress-circular>
      </div>
    </v-container>
  </template>
  
  <script>
  import http from "@/Services/http.js";
  import moment from "moment";
  
  export default {
    data: () => ({
c50650743   Amber Dev   added Announcemen...
157
      localStorage: localStorage,
640ed7acb   Neeraj Sharma   implement annouce...
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
      snackbar: false,
      y: "top",
      x: "right",
      mode: "",
      timeout: 3000,
      text: "",
      showLoader: false,
      loading: false,
      date: null,
      token: "",
      role: "",
      schoolRole: "",
      menu: false,
      annoucementData: {},
      showReplyBox: false,
      replyDescription: "",
      loginId: "",
860da881d   Shikha Mishra   comment all consoles
175
      editedIndex: -1,
640ed7acb   Neeraj Sharma   implement annouce...
176
177
    }),
    methods: {
860da881d   Shikha Mishra   comment all consoles
178
      dates: function (date) {
640ed7acb   Neeraj Sharma   implement annouce...
179
180
181
182
183
184
185
186
        return moment(date).format("MMMM DD, YYYY hh:mm A");
      },
      getDiscussionesThread() {
        // console.log("id", this.getSelectedData.courseId);
        this.showLoader = true;
        http()
          .get("/getParticularAnnoucement", {
            params: {
860da881d   Shikha Mishra   comment all consoles
187
188
              annoucementId: this.$route.params.annoucementId,
            },
640ed7acb   Neeraj Sharma   implement annouce...
189
          })
860da881d   Shikha Mishra   comment all consoles
190
          .then((response) => {
640ed7acb   Neeraj Sharma   implement annouce...
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
            //   console.log("response", response.data.data);
            this.annoucementData = response.data.data;
            // console.log("response", this.annoucementData);
            for (let i = 0; i < this.annoucementData.length; i++) {
              for (
                let j = 0;
                j < this.annoucementData[i].discussionThread.length;
                j++
              ) {
                if (this.annoucementData[i].discussionThread[j]) {
                  this.annoucementData[i].discussionThread[
                    j
                  ].showUpdateReplyThread = false;
                  this.annoucementData[i].discussionThread[
                    j
                  ].showDescriptionReplyThread = true;
                }
              }
            }
            this.showLoader = false;
            this.showReplyBox = false;
          })
860da881d   Shikha Mishra   comment all consoles
213
214
          .catch((error) => {
            //   console.log("err====>", error);
640ed7acb   Neeraj Sharma   implement annouce...
215
            this.showLoader = false;
860da881d   Shikha Mishra   comment all consoles
216
217
218
            this.snackbar = true;
            this.color = "error";
            this.text = error.response.data.message;
640ed7acb   Neeraj Sharma   implement annouce...
219
220
221
222
223
224
225
          });
      },
      replyThreadDiscussion() {
        this.showLoader = true;
        var payloadData = {
          annoucementId: this.$route.params.annoucementId,
          teacherId: this.loginId,
860da881d   Shikha Mishra   comment all consoles
226
          description: this.replyDescription,
640ed7acb   Neeraj Sharma   implement annouce...
227
228
229
        };
        http()
          .put("/replyThread", payloadData)
860da881d   Shikha Mishra   comment all consoles
230
          .then((response) => {
640ed7acb   Neeraj Sharma   implement annouce...
231
232
233
234
            //   console.log("response", response.data.data);
            this.showLoader = false;
            this.getDiscussionesThread();
          })
860da881d   Shikha Mishra   comment all consoles
235
          .catch((error) => {
640ed7acb   Neeraj Sharma   implement annouce...
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
            this.showLoader = false;
          });
      },
      showUpdateReplyThreadDiscussion(item) {
        this.editedIndex = this.annoucementData.indexOf(item);
        var editedItem = Object.assign({}, item);
        var arrayOfannoucementData = [];
        for (let i = 0; i < this.annoucementData.length; i++) {
          for (
            let j = 0;
            j < this.annoucementData[i].discussionThread.length;
            j++
          ) {
            if (
              editedItem._id == this.annoucementData[i].discussionThread[j]._id
            ) {
              this.annoucementData[i].discussionThread[
                j
              ].showUpdateReplyThread = true;
              this.annoucementData[i].discussionThread[
                j
              ].showDescriptionReplyThread = false;
            }
          }
          arrayOfannoucementData.push(this.annoucementData[i]);
        }
        this.annoucementData = arrayOfannoucementData;
      },
      updateRelpyThreadDiscussion(replyThread) {
        this.showLoader = true;
        var payloadData = {
          discussionThreadId: replyThread._id,
          annoucementId: this.$route.params.annoucementId,
          teacherId: this.loginId,
860da881d   Shikha Mishra   comment all consoles
270
          description: replyThread.description,
640ed7acb   Neeraj Sharma   implement annouce...
271
272
273
        };
        http()
          .put("/updateThread", payloadData)
860da881d   Shikha Mishra   comment all consoles
274
          .then((response) => {
640ed7acb   Neeraj Sharma   implement annouce...
275
276
277
            this.showLoader = false;
            this.getDiscussionesThread();
          })
860da881d   Shikha Mishra   comment all consoles
278
          .catch((error) => {
640ed7acb   Neeraj Sharma   implement annouce...
279
280
281
282
283
284
285
            this.showLoader = false;
          });
      },
      deleteRelpyThreadDiscussion(id) {
        this.showLoader = true;
        var payloadData = {
          discussionThreadId: id,
860da881d   Shikha Mishra   comment all consoles
286
          annoucementId: this.$route.params.annoucementId,
640ed7acb   Neeraj Sharma   implement annouce...
287
288
289
290
291
292
        };
        http()
          .put(
            "/deleteThread",
            confirm("Are you sure you want to delete this?") && payloadData
          )
860da881d   Shikha Mishra   comment all consoles
293
          .then((response) => {
640ed7acb   Neeraj Sharma   implement annouce...
294
295
296
            this.showLoader = false;
            this.getDiscussionesThread();
          })
860da881d   Shikha Mishra   comment all consoles
297
          .catch((error) => {
640ed7acb   Neeraj Sharma   implement annouce...
298
299
            this.showLoader = false;
          });
860da881d   Shikha Mishra   comment all consoles
300
      },
640ed7acb   Neeraj Sharma   implement annouce...
301
302
303
304
305
306
307
    },
    mounted() {
      // this.getStudentList();
      this.token = this.$store.state.token;
      this.role = this.$store.state.role;
      this.loginId = this.$store.state.id;
      this.getDiscussionesThread();
860da881d   Shikha Mishra   comment all consoles
308
    },
640ed7acb   Neeraj Sharma   implement annouce...
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
  };
  </script>
  
  <style>
  .reply-desc {
    border: 1px solid #f2f2f2;
  }
  .open-dialog-button {
    background: #827bfa !important;
    border-color: #827bfa !important;
    text-transform: none !important;
  }
  
  .reply-btn {
    background: #feb83c !important;
    border-color: #feb83c !important;
    text-transform: none !important;
    -webkit-box-shadow: none !important;
    box-shadow: none !important;
  }
  </style>