Skip to content

Commit 6330d65

Browse files
committed
Undo the ts setting in vue components, begin migration to Vue.component setup
1 parent 0e1d35c commit 6330d65

35 files changed

+179
-198
lines changed

resources/assets/scripts/components/Flash.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
</div>
1313
</template>
1414

15-
<script lang="ts">
15+
<script>
1616
import MessageBox from './MessageBox.vue';
1717
1818
export default {

resources/assets/scripts/components/MessageBox.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
</div>
66
</template>
77

8-
<script lang="ts">
8+
<script>
99
export default {
1010
name: 'message-box',
1111
props: {

resources/assets/scripts/components/auth/ForgotPassword.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
</div>
3737
</template>
3838

39-
<script lang="ts">
39+
<script>
4040
export default {
4141
name: 'forgot-password',
4242
props: {
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import Vue from 'vue';
2+
import LoginForm from "./LoginForm";
3+
4+
export default Vue.component('login', {
5+
data: function () {
6+
return {
7+
user: {
8+
email: ''
9+
},
10+
};
11+
},
12+
components: {
13+
LoginForm,
14+
},
15+
methods: {
16+
onUpdateEmail: function (value: string) {
17+
this.$data.user.email = value;
18+
},
19+
},
20+
template: `
21+
<div>
22+
<!--<flash container="mb-2"/>-->
23+
<login-form
24+
v-if="this.$route.name === 'login'"
25+
v-bind:user="user"
26+
v-on:update-email="onUpdateEmail"
27+
/>
28+
<!--<forgot-password-->
29+
<!--v-if="this.$route.name === 'forgot-password'"-->
30+
<!--v-bind:email="user.email"-->
31+
<!--v-on:update-email="onUpdateEmail"-->
32+
<!--/>-->
33+
<!--<two-factor-form v-if="this.$route.name === 'checkpoint'" />-->
34+
</div>
35+
`,
36+
});

resources/assets/scripts/components/auth/Login.vue

Lines changed: 0 additions & 46 deletions
This file was deleted.
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
import Vue from 'vue';
2+
import {isObject} from 'lodash';
3+
4+
export default Vue.component('login-form', {
5+
props: {
6+
user: {
7+
type: Object,
8+
required: false,
9+
default: function () {
10+
return {
11+
email: '',
12+
password: '',
13+
};
14+
},
15+
}
16+
},
17+
data: function () {
18+
return {
19+
showSpinner: false,
20+
}
21+
},
22+
mounted: function () {
23+
(this.$refs.email as HTMLElement).focus();
24+
},
25+
methods: {
26+
// Handle a login request eminating from the form. If 2FA is required the
27+
// user will be presented with the 2FA modal window.
28+
submitForm: function () {
29+
const self = this;
30+
this.$data.showSpinner = true;
31+
32+
this.$flash.clear();
33+
this.$store.dispatch('auth/login', {user: this.$props.user.email, password: this.$props.user.password})
34+
.then(response => {
35+
if (response.complete) {
36+
return window.location = response.intended;
37+
}
38+
39+
this.$props.user.password = '';
40+
this.$data.showSpinner = false;
41+
this.$router.push({name: 'checkpoint', query: {token: response.token}});
42+
})
43+
.catch(err => {
44+
this.$props.user.password = '';
45+
this.$data.showSpinner = false;
46+
(this.$refs.password as HTMLElement).focus();
47+
this.$store.commit('auth/logout');
48+
49+
if (!err.response) {
50+
return console.error(err);
51+
}
52+
53+
const response = err.response;
54+
if (response.data && isObject(response.data.errors)) {
55+
response.data.errors.forEach(function (error: any) {
56+
self.$flash.error(error.detail);
57+
});
58+
}
59+
});
60+
},
61+
62+
// Update the email address associated with the login form
63+
// so that it is populated in the parent model automatically.
64+
updateEmail: function (event: { target: HTMLInputElement }) {
65+
this.$emit('update-email', event.target.value);
66+
}
67+
},
68+
template: `
69+
<form class="login-box" method="post"
70+
v-on:submit.prevent="submitForm"
71+
>
72+
<div class="flex flex-wrap -mx-3 mb-6">
73+
<div class="input-open">
74+
<input class="input open-label" id="grid-username" type="text" name="user" aria-labelledby="grid-username-label" required
75+
ref="email"
76+
:class="{ 'has-content' : user.email.length > 0 }"
77+
:readonly="showSpinner"
78+
:value="user.email"
79+
v-on:input="updateEmail($event)"
80+
/>
81+
<label id="grid-username-label" for="grid-username">{{ $t('strings.user_identifier') }}</label>
82+
</div>
83+
</div>
84+
<div class="flex flex-wrap -mx-3 mb-6">
85+
<div class="input-open">
86+
<input class="input open-label" id="grid-password" type="password" name="password" aria-labelledby="grid-password-label" required
87+
ref="password"
88+
:class="{ 'has-content' : user.password && user.password.length > 0 }"
89+
:readonly="showSpinner"
90+
v-model="user.password"
91+
/>
92+
<label id="grid-password-label" for="grid-password">{{ $t('strings.password') }}</label>
93+
</div>
94+
</div>
95+
<div>
96+
<button id="grid-login-button" class="btn btn-blue btn-jumbo" type="submit" aria-label="Log in"
97+
v-bind:disabled="showSpinner">
98+
<span class="spinner white" v-bind:class="{ hidden: ! showSpinner }">&nbsp;</span>
99+
<span v-bind:class="{ hidden: showSpinner }">
100+
{{ $t('auth.sign_in') }}
101+
</span>
102+
</button>
103+
</div>
104+
<div class="pt-6 text-center">
105+
<router-link class="text-xs text-grey tracking-wide no-underline uppercase hover:text-grey-dark" aria-label="Forgot password"
106+
:to="{ name: 'forgot-password' }">
107+
{{ $t('auth.forgot_password.label') }}
108+
</router-link>
109+
</div>
110+
</form>
111+
`,
112+
});

resources/assets/scripts/components/auth/LoginForm.vue

Lines changed: 0 additions & 115 deletions
This file was deleted.

resources/assets/scripts/components/auth/ResetPassword.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
</div>
5656
</template>
5757

58-
<script lang="ts">
58+
<script>
5959
export default {
6060
name: "ResetPassword",
6161
props: {

resources/assets/scripts/components/auth/TwoFactorForm.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
</form>
2929
</template>
3030

31-
<script lang="ts">
31+
<script>
3232
export default {
3333
name: "two-factor-form",
3434
data: function () {

resources/assets/scripts/components/core/Modal.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
</transition>
1212
</template>
1313

14-
<script lang="ts">
14+
<script>
1515
import { XIcon } from 'vue-feather-icons';
1616
export default {
1717
name: 'modal',

0 commit comments

Comments
 (0)