Skip to content

Commit

Permalink
Sync
Browse files Browse the repository at this point in the history
  • Loading branch information
acacha committed Dec 18, 2017
1 parent e14874c commit af74be2
Show file tree
Hide file tree
Showing 31 changed files with 939 additions and 115 deletions.
18 changes: 18 additions & 0 deletions resources/assets/js/acacha-users/.eslintrc.js
@@ -0,0 +1,18 @@
module.exports = {
root: true,
extends: 'standard',
parser: 'babel-eslint',
parserOptions: {
sourceType: 'module'
},
plugins: [
'html',
'standard',
'promise',
'you-dont-need-lodash-underscore'
],
rules: {
'you-dont-need-lodash-underscore/for-each': 1,
'you-dont-need-lodash-underscore/concat': 1
}
};
3 changes: 1 addition & 2 deletions resources/assets/js/acacha-users/components/CreateUser.vue
Expand Up @@ -64,7 +64,6 @@
<style src="./css/fade.css"></style>

<script>
import Form from 'acacha-forms'
import {Box} from 'adminlte-vue'
Expand All @@ -79,7 +78,7 @@
}
},
components: {
'adminlte-vue-box' : Box
'adminlte-vue-box': Box
},
props: {
apiUri: {
Expand Down
51 changes: 32 additions & 19 deletions resources/assets/js/acacha-users/index.js
Expand Up @@ -5,21 +5,35 @@ import CreateUserViaInvitation from './components/CreateUserViaInvitation.vue'
import UsersDashboard from './components/dashboard/UsersDashboard.vue'
import ModelTracking from './components/tracking/ModelTracking.vue'

//PROFILE
// Vuex Modules
import {AcachaUsersModule} from './store/modules/user'
import {UserProfileStoreComponent} from './user-profile/base-components/UserProfileStoreComponent'

import UserProfileStore from './store'

// PROFILE
import UserProfile from './user-profile/UserProfileComponent.vue'
import UserProfileInfoBox from './user-profile/components/UserProfileInfoBoxComponent.vue'

//MAIN
// MAIN
import UserForm from './main/UserForm.vue'
import LoggedUserForm from './main/LoggedUserForm.vue'
import LoggedUserNoPasswordForm from './main/LoggedUserNoPasswordForm.vue'
import LoggedUserNameForm from './main/LoggedUserNameForm.vue'
import LoggedUserEmailForm from './main/LoggedUserEmailForm.vue'
import LoggedUserPasswordForm from './main/LoggedUserPasswordForm.vue'

//Full screen components:
// Full screen components:
import RegisterUserByEmail from './components/RegisterUserByEmail.vue'
import InviteUserFullScreen from './components/invitations/InviteUserFullScreen.vue'

// Google Apps vue components
import GoogleAppsDashboard from './components/google/GoogleAppsDashboard.vue'
import GoogleAppsUsersList from './components/google/GoogleAppsUsersList.vue'

import Vue from 'vue'
import { config } from './config/ebre-escool-users-migration'

// auto install
if (typeof window !== 'undefined' && window.Vue) {
// Register components
Expand All @@ -32,28 +46,29 @@ if (typeof window !== 'undefined' && window.Vue) {
// // expose AdminlteVue functions if auto installed
// window.Vue.$adminlte = {todo, todo2}

//Full screen components:
// Full screen components:
Vue.component('register-user-by-email', RegisterUserByEmail)
Vue.component('invite-user-fullscreen', InviteUserFullScreen)

// Google Apps vue components
Vue.component('google-apps-dashboard', GoogleAppsDashboard)
Vue.component('google-apps-users-list', GoogleAppsUsersList)

//Profile
// Profile
Vue.component('user-profile', UserProfile)
Vue.component('user-profile-info-box', UserProfileInfoBox)

//Main
// Main
Vue.component('user-form', UserForm)
Vue.component('logged-user-form', LoggedUserForm)
Vue.component('logged-user-name-form', LoggedUserNameForm)
Vue.component('logged-user-email-form', LoggedUserEmailForm)
}

import { config } from './config/ebre-escool-users-migration'

window.acacha_users = {}
window.acacha_users.config = config

//Components
// Components
export {
UsersManagement,
UserInvitations,
Expand All @@ -67,25 +82,23 @@ export {
GoogleAppsUsersList,
UserProfile,
UserProfileInfoBox,
UserForm
UserForm,
LoggedUserForm,
LoggedUserNoPasswordForm,
LoggedUserNameForm,
LoggedUserEmailForm,
LoggedUserPasswordForm
}

import UserProfileStore from './store'

//Stores
// Stores
export {
UserProfileStore
}

//Vuex Modules
import {AcachaUsersModule} from './store/modules/user'

export {
AcachaUsersModule
}

import {UserProfileStoreComponent} from './user-profile/base-components/UserProfileStoreComponent'

export {
UserProfileStoreComponent
}
}
57 changes: 57 additions & 0 deletions resources/assets/js/acacha-users/main/LoggedUserEmailForm.vue
@@ -0,0 +1,57 @@
<template>
<div>
<adminlte-alert :alert="alert"></adminlte-alert>
<form role="form" method="post" @submit.prevent="submit" @keydown="clearErrors($event.target.name)">
<adminlte-input-password name="current_password" :form-name="formName"></adminlte-input-password>
<adminlte-input-email :form-name="formName"></adminlte-input-email>
<div class="box-footer">
<button type="submit" class="btn btn-primary" :disabled="isDisabled()">Change email</button>
</div>
</form>
</div>
</template>

<script>
import { AdminlteInputEmailComponent, AdminlteInputPasswordComponent } from 'acacha-adminlte-vue-forms'
import { FlashMixin, DisabledSubmitMixin } from 'adminlte-vue'
import Form, { FormsModule, UsesAcachaForms, registerForm, ClearErrorsMixin } from 'acacha-forms'
import InteractsWithUser from './mixins/interactsWithUser'
import SubmitsFormField from './mixins/SubmitsFormField'
const UserEmailForm = new Form({
current_password: '',
email: ''
})
const API_ENDPOINT = '/api/v1/user/email'
const ACACHA_FORM = FormsModule(UserEmailForm)
const ACACHA_FORM_VUEX_MODULE = 'logged-user-email-form'
export default {
name: 'LoggedUserEmailForm',
components: { AdminlteInputEmailComponent, AdminlteInputPasswordComponent },
mixins: [FlashMixin, DisabledSubmitMixin, InteractsWithUser, UsesAcachaForms, ClearErrorsMixin, SubmitsFormField],
methods: {
submit () {
this.submitFormField('put', API_ENDPOINT, 'Email')
},
fillForm () {
// Update Form object with Current User
const fields = [
{
field: 'name',
value: this.user.name
},
{
field: 'email',
value: this.user.email
}
]
this.updateForm(fields)
}
},
beforeCreate () {
registerForm(this, ACACHA_FORM_VUEX_MODULE, ACACHA_FORM)
}
}
</script>
60 changes: 60 additions & 0 deletions resources/assets/js/acacha-users/main/LoggedUserForm.vue
@@ -0,0 +1,60 @@
<template>
<div>
<adminlte-alert :alert="alert"></adminlte-alert>
<form role="form" method="post" @submit.prevent="submit" @keydown="clearErrors($event.target.name)">
<adminlte-input-text name="name" :form-name="formName"></adminlte-input-text>
<adminlte-input-email :form-name="formName"></adminlte-input-email>
<adminlte-input-password :form-name="formName"></adminlte-input-password>
<div class="box-footer">
<button type="submit" class="btn btn-primary" :disabled="isDisabled()">Update</button>
</div>
</form>
</div>
</template>


<script>
import { AdminlteInputTextComponent, AdminlteInputEmailComponent, AdminlteInputPasswordComponent } from 'acacha-adminlte-vue-forms'
import {FlashMixin, DisabledSubmitMixin} from 'adminlte-vue'
import Form, { FormsModule, UsesAcachaForms, registerForm, ClearErrorsMixin } from 'acacha-forms'
import InteractsWithUser from './mixins/interactsWithUser'
import SubmitsFormWithMessage from './mixins/SubmitsFormWithMessage'
const LoggedUserForm = new Form({
name: '',
email: '',
passsword: ''
})
const API_ENDPOINT = '/api/v1/user'
const ACACHA_FORM = FormsModule(LoggedUserForm)
const ACACHA_FORM_VUEX_MODULE = 'user-form'
export default {
name: 'LoggedUserForm',
components: { AdminlteInputTextComponent, AdminlteInputEmailComponent, AdminlteInputPasswordComponent },
mixins: [FlashMixin, DisabledSubmitMixin, UsesAcachaForms, InteractsWithUser, ClearErrorsMixin, SubmitsFormWithMessage],
methods: {
submit () {
this.submitFormWithMessage('put', API_ENDPOINT, 'User changed ok!')
},
fillForm () {
// Update Form object with Current User
const fields = [
{
field: 'name',
value: this.user.name
},
{
field: 'email',
value: this.user.email
}
]
this.updateForm(fields)
}
},
beforeCreate () {
registerForm(this, ACACHA_FORM_VUEX_MODULE, ACACHA_FORM)
}
}
</script>
51 changes: 51 additions & 0 deletions resources/assets/js/acacha-users/main/LoggedUserNameForm.vue
@@ -0,0 +1,51 @@
<template>
<div>
<adminlte-alert :alert="alert"></adminlte-alert>
<form role="form" method="post" @submit.prevent="submit" @keydown="clearErrors($event.target.name)">
<adminlte-input-text name="name" :form-name="formName"></adminlte-input-text>
<div class="box-footer">
<button type="submit" class="btn btn-primary" :disabled="isDisabled()">Change name</button>
</div>
</form>
</div>
</template>

<script>
import { AdminlteInputTextComponent } from 'acacha-adminlte-vue-forms'
import { FlashMixin, DisabledSubmitMixin } from 'adminlte-vue'
import Form, { FormsModule, UsesAcachaForms, registerForm, ClearErrorsMixin } from 'acacha-forms'
import InteractsWithUser from './mixins/interactsWithUser'
import SubmitsFormField from './mixins/SubmitsFormField'
const UserNameForm = new Form({
name: ''
})
const API_ENDPOINT = '/api/v1/user/name'
const ACACHA_FORM = FormsModule(UserNameForm)
const ACACHA_FORM_VUEX_MODULE = 'logged-user-name-form'
export default {
name: 'LoggedUserNameForm',
components: { AdminlteInputTextComponent },
mixins: [FlashMixin, DisabledSubmitMixin, InteractsWithUser, UsesAcachaForms, ClearErrorsMixin, SubmitsFormField],
methods: {
submit () {
this.submitFormField('put', API_ENDPOINT, 'Name')
},
fillForm () {
// Update Form object with Current User
const fields = [
{
field: 'name',
value: this.user.name
}
]
this.updateForm(fields)
}
},
beforeCreate () {
registerForm(this, ACACHA_FORM_VUEX_MODULE, ACACHA_FORM)
}
}
</script>
58 changes: 58 additions & 0 deletions resources/assets/js/acacha-users/main/LoggedUserNoPasswordForm.vue
@@ -0,0 +1,58 @@
<template>
<div>
<adminlte-alert :alert="alert"></adminlte-alert>
<form role="form" method="post" @submit.prevent="submit" @keydown="clearErrors($event.target.name)">
<adminlte-input-text name="name" :form-name="formName"></adminlte-input-text>
<adminlte-input-email :form-name="formName"></adminlte-input-email>
<div class="box-footer">
<button type="submit" class="btn btn-primary" :disabled="isDisabled()">Update</button>
</div>
</form>
</div>
</template>


<script>
import { AdminlteInputTextComponent, AdminlteInputEmailComponent } from 'acacha-adminlte-vue-forms'
import {FlashMixin, DisabledSubmitMixin} from 'adminlte-vue'
import Form, { FormsModule, UsesAcachaForms, registerForm, ClearErrorsMixin } from 'acacha-forms'
import InteractsWithUser from './mixins/interactsWithUser'
import SubmitsFormWithMessage from './mixins/SubmitsFormWithMessage'
const UserNoPasswordForm = new Form({
name: '',
email: ''
})
const API_ENDPOINT = '/api/v1/user'
const ACACHA_FORM = FormsModule(UserNoPasswordForm)
const ACACHA_FORM_VUEX_MODULE = 'logged-user-no-password-form'
export default {
name: 'LoggedUserNoPasswordForm',
components: { AdminlteInputTextComponent, AdminlteInputEmailComponent },
mixins: [FlashMixin, DisabledSubmitMixin, InteractsWithUser, UsesAcachaForms, ClearErrorsMixin, SubmitsFormWithMessage],
methods: {
submit () {
this.submitFormWithMessage('put', API_ENDPOINT, 'User changed ok!')
},
fillForm () {
// Update Form object with Current User
const fields = [
{
field: 'name',
value: this.user.name
},
{
field: 'email',
value: this.user.email
}
]
this.updateForm(fields)
}
},
beforeCreate () {
registerForm(this, ACACHA_FORM_VUEX_MODULE, ACACHA_FORM)
}
}
</script>

0 comments on commit af74be2

Please sign in to comment.