Blame view

src/pages/Dashboard.vue 5.58 KB
93a68cfa1   Jatinder Singh   first commit
1
2
  <template>
  <v-tabs
04e3fbc56   Jatinder Singh   minor fix
3
4
  
    slider-color="black"
93a68cfa1   Jatinder Singh   first commit
5
  >
04e3fbc56   Jatinder Singh   minor fix
6
   <v-spacer></v-spacer>
93a68cfa1   Jatinder Singh   first commit
7
8
9
10
11
12
13
14
15
16
17
18
19
20
    <v-tab ripple>
      Existing user
    </v-tab>
    <v-spacer></v-spacer>
    <v-tab ripple>
      Add New Users
    </v-tab>
    <v-spacer></v-spacer>
    <v-tab-item>
      <v-card flat>
        <v-card-text>
        <v-data-table
        :headers="headers"
        :items="desserts"
93a68cfa1   Jatinder Singh   first commit
21
22
        class="elevation-1">
      <template slot="items" slot-scope="props">
04e3fbc56   Jatinder Singh   minor fix
23
24
25
    <td>{{ props.item.No }}</td>
    <td>{{ props.item.Name }}</td>
    <td>{{ props.item.Email }}</td>
93a68cfa1   Jatinder Singh   first commit
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
      <!-- <td><v-flex xs6>
      </v-flex></td> -->
          <td class="justify-center layout px-0">
            <v-icon
              small
              class="mr-2"
              @click="report(props.item)"
            >
              visibility
            </v-icon>
              <v-icon
              small
              class="mr-2"
              @click="editItem(props.item)"
            >
              edit
            </v-icon>
            <v-icon
              small
              @click="deleteItem(props.item)"
            >
              delete
            </v-icon>
          </td>
        </template>
      </v-data-table>
04e3fbc56   Jatinder Singh   minor fix
52
53
     </v-card-text>
    </v-card>
93a68cfa1   Jatinder Singh   first commit
54
55
56
57
58
    </v-tab-item>
    <v-tab-item>
         <v-flex xs12 sm6 offset-sm3>
   
   
04e3fbc56   Jatinder Singh   minor fix
59
  <v-card flat>
93a68cfa1   Jatinder Singh   first commit
60
        <!-- <v-card-text>Contents for Item 2 go here</v-card-text> -->
04e3fbc56   Jatinder Singh   minor fix
61
    <v-container fluid fill-height>
93a68cfa1   Jatinder Singh   first commit
62
      <v-layout align-center>
04e3fbc56   Jatinder Singh   minor fix
63
64
65
        <v-flex xs12 sm8 offset-sm2> 
         <v-flex offset-sm5>
          <v-avatar size="40px"> 
93a68cfa1   Jatinder Singh   first commit
66
          <img src="/static/avatar/download.png"/> </v-avatar> 
04e3fbc56   Jatinder Singh   minor fix
67
68
        </v-flex>
         <v-form>
93a68cfa1   Jatinder Singh   first commit
69
70
          
              <v-text-field
04e3fbc56   Jatinder Singh   minor fix
71
                v-validate="'required|FName'"
93a68cfa1   Jatinder Singh   first commit
72
73
                label="First name"
                class="mt-5"
04e3fbc56   Jatinder Singh   minor fix
74
75
                v-model="FName"
                :rules="[() => FName.length > 0 || 'This field is required']"
93a68cfa1   Jatinder Singh   first commit
76
77
78
                required
              ></v-text-field>
              <v-text-field
04e3fbc56   Jatinder Singh   minor fix
79
              v-validate="'required|LName'"
93a68cfa1   Jatinder Singh   first commit
80
              label="Last name"
04e3fbc56   Jatinder Singh   minor fix
81
82
              v-model="LName"
              :rules="[() => LName.length > 0 || 'This field is required']"
93a68cfa1   Jatinder Singh   first commit
83
84
85
              required
      ></v-text-field>
      <v-text-field
93a68cfa1   Jatinder Singh   first commit
86
        v-model="email"
04e3fbc56   Jatinder Singh   minor fix
87
        :rules="[erules.required, erules.em]"
93a68cfa1   Jatinder Singh   first commit
88
89
90
91
92
93
94
95
96
        label="E-mail"
        data-vv-name="email"
        required>
      </v-text-field>
      
   
      <v-text-field
         v-model="DOB"
         label="Date of Birth"
04e3fbc56   Jatinder Singh   minor fix
97
         
93a68cfa1   Jatinder Singh   first commit
98
         persistent-hint
04e3fbc56   Jatinder Singh   minor fix
99
        :rules="[rules.required, rules.min]"
93a68cfa1   Jatinder Singh   first commit
100
101
102
         required >
      </v-text-field>
    <v-card-actions>
04e3fbc56   Jatinder Singh   minor fix
103
    <v-btn @click="clear" round dark>clear</v-btn>
93a68cfa1   Jatinder Singh   first commit
104
    <v-spacer></v-spacer>
04e3fbc56   Jatinder Singh   minor fix
105
    <v-btn @click="submit" round dark>Add</v-btn></v-card-actions>
93a68cfa1   Jatinder Singh   first commit
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
  </v-form>
  </v-flex>
  </v-layout>
  </v-container>
      </v-card>
         </v-flex>
    </v-tab-item>  
  </v-tabs>
  
   
  </template>
  
  <script>
  import Vue from 'vue';
  import VeeValidate from 'vee-validate';
  Vue.use(VeeValidate);
  export default {
    $_veeValidate: {
      validator: 'new'
    },
    data: () => ({
04e3fbc56   Jatinder Singh   minor fix
127
128
      FName: '',
      LName: '',
93a68cfa1   Jatinder Singh   first commit
129
130
      DOB: '',
      email: '',
04e3fbc56   Jatinder Singh   minor fix
131
      clear: '',
93a68cfa1   Jatinder Singh   first commit
132
133
134
      search: '',
      dialog: false,
      state: ['Pending', 'Approved'],
04e3fbc56   Jatinder Singh   minor fix
135
136
137
138
139
140
141
142
143
      rules: {
        required: value => !!value || 'This field is Required.',
        min: v => (/^(0?[1-9]|[12][0-9]|3[01])[\/\-](0?[1-9]|1[012])[\/\-]\d{4}$/).test(v) && v.length > 0 || 'Please enter a date in the format dd/mm/yyyy'
          
      },
      erules: {
        required: value => !!value || 'This email field is Required.', 
        em: v => (v.length > 0 && /^\w+([.-]?\w+)*@\w+([.-]?\w+)*(\.\w{2,3})+$/.test(v) || 'Email must be valid') 
      },
93a68cfa1   Jatinder Singh   first commit
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
      headers: [
        {
          text: 'No',
          align: 'left',
          sortable: false,
          value: 'name'
        },
        { text: 'Name', value: 'Name', sortable: false },
        { text: 'Email', value: 'Email', sortable: false },
        // { text: 'Status', value: 'Status', sortable: false },
        // { text: 'Actions', value: 'name', sortable: false, align: 'center', }
      ],
      desserts: [],
      editedIndex: -1,
      editedItem: {
        No: '',
        Name: '',
        Email: '',
      },
      defaultItem: {
        No: '',
        Name: '',
        Email: '',
      },
    }),
93a68cfa1   Jatinder Singh   first commit
169
170
171
172
173
    mounted () {
      this.$validator.localize('en', this.dictionary);
    },
  
    methods: {
93a68cfa1   Jatinder Singh   first commit
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
      initialize () {
        this.desserts = [
          {
            No: 1,
            Name: 'amit',
            Email: 'jsi@gmail.com',
            DOB: '22/09/1996'
          },
          {
            No: 2,
            Name: 'sumit',
            Email: 'aasi@gmail.com',
            DOB: '16/09/1997'
          }
        ];
      },
  
      editItem (item) {
        this.editedIndex = this.desserts.indexOf(item);
        this.editedItem = Object.assign({}, item);
        this.dialog = true;
      },
a259e694f   Jatinder Singh   minor change
196
197
198
      submit () {
        this.$validator.validateAll();
      },
93a68cfa1   Jatinder Singh   first commit
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
  
      // report (item) {
      //   this.reportIndex = this.desserts.indexOf(item);
      //   this.reportItem = Object.assign({}, item);
      //   this.report = true;
      // },
  
      deleteItem (item) {
        const index = this.desserts.indexOf(item);
        confirm('Are you sure you want to delete this item?') &&
          this.desserts.splice(index, 1);
      },
  
      close () {
        this.dialog = false;
        setTimeout(() => {
          this.editedItem = Object.assign({}, this.defaultItem);
          this.editedIndex = -1;
        }, 300);
      },
  
      save () {
        if (this.editedIndex > -1) {
          Object.assign(this.desserts[this.editedIndex], this.editedItem);
        } else {
          this.desserts.push(this.editedItem);
        }
        this.close();
      }
    }, 
  
    clear () {
04e3fbc56   Jatinder Singh   minor fix
231
232
      this.FName = '';
      this.LName = '';
93a68cfa1   Jatinder Singh   first commit
233
234
      this.email = '';
      this.DOB = '';
a259e694f   Jatinder Singh   minor change
235
    
93a68cfa1   Jatinder Singh   first commit
236
237
      // this.select = null;
      // this.checkbox = null;
a259e694f   Jatinder Singh   minor change
238
      this.$validator.reset();
07095d4d8   Jatinder Singh   regex
239
    
93a68cfa1   Jatinder Singh   first commit
240
241
242
243
    }
  };
  
  </script>
04e3fbc56   Jatinder Singh   minor fix
244
245
246
247
248
249
  <style scoped>
  .v-card__actions .v-btn{
    margin: 0 15px;
    min-width: 120px;
  }
  </style>