Added profile edit page
This commit is contained in:
@@ -12,7 +12,6 @@ var createPost = {
|
||||
category.loadList(1)
|
||||
},
|
||||
oncreate: function() {
|
||||
clearInterval(window.intv)
|
||||
var valid_at = rome(left, {
|
||||
dateValidator: rome.val.beforeEq(right),
|
||||
time: false,
|
||||
|
||||
@@ -46,6 +46,17 @@ var nav = {
|
||||
}),
|
||||
' User'
|
||||
]) : null,
|
||||
m('a.navy.button', {
|
||||
'data-tooltip': 'Profil',
|
||||
onclick: function() {
|
||||
m.route.set('/user/' + window.location.search.split('&')[1].slice('2'))
|
||||
}
|
||||
}, [
|
||||
m('i.fa.fa-user-circle-o', {
|
||||
'aria-hidden': 'true'
|
||||
}),
|
||||
' Profil'
|
||||
]),
|
||||
m('a.navy.button', {
|
||||
'data-tooltip': 'Keluar',
|
||||
onclick: function() {user.logout()}
|
||||
|
||||
@@ -23,6 +23,9 @@ var showPost = {
|
||||
style: 'padding: 0 .6em'
|
||||
}, m(listAdmin))
|
||||
])))
|
||||
},
|
||||
onremove: function() {
|
||||
clearInterval(window.intv)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
110
assets/js/components/userProfile.js
Normal file
110
assets/js/components/userProfile.js
Normal file
@@ -0,0 +1,110 @@
|
||||
let m = require('mithril')
|
||||
let fecha = require('fecha')
|
||||
let user = require('../models/user')
|
||||
let Loading = require('./Loading')
|
||||
|
||||
var userProfile = {
|
||||
changePassword: false,
|
||||
oninit: function(vnode) {
|
||||
user.current = {}
|
||||
user.loadCurrent(vnode.attrs.id)
|
||||
},
|
||||
oncreate: function() {
|
||||
userProfile.changePassword = false
|
||||
},
|
||||
view: function() {
|
||||
return m('main.documentation', m('section', [
|
||||
user.loading ? m(Loading) :
|
||||
m('form', {
|
||||
onsubmit: function(e) {
|
||||
e.preventDefault()
|
||||
user.editProfile()
|
||||
}
|
||||
}, [
|
||||
m('h1', m('input', {
|
||||
type: 'text',
|
||||
required: 'required',
|
||||
placeholder: 'Nama Lengkap',
|
||||
value: user.current.full_name,
|
||||
onclick: function() {
|
||||
user.current.full_name = ''
|
||||
},
|
||||
oninput: m.withAttr('value', function(value) {
|
||||
user.current.full_name = value
|
||||
})
|
||||
})),
|
||||
m('table.full', [
|
||||
m('tr.full', [
|
||||
m('td', 'Username'),
|
||||
m('td', ':'),
|
||||
m('td', user.current.username)
|
||||
]),
|
||||
m('tr', [
|
||||
m('td', 'Password'),
|
||||
m('td', ':'),
|
||||
m('td', [
|
||||
m('input.full.noTrans#nPwd', {
|
||||
type: 'password',
|
||||
required: 'required',
|
||||
placeholder: 'Password Baru',
|
||||
value: user.current.new_password,
|
||||
onclick: function() {
|
||||
user.current.new_password = ''
|
||||
this.className = 'third noTrans'
|
||||
userProfile.changePassword = true
|
||||
},
|
||||
oninput: m.withAttr('value', function(value) {
|
||||
user.current.new_password = value
|
||||
})
|
||||
}),
|
||||
m('input.third#oPwd', {
|
||||
type: 'password',
|
||||
required: 'required',
|
||||
style: userProfile.changePassword ?
|
||||
'display: inline-block;'
|
||||
: 'display: none;',
|
||||
placeholder: 'Password Lama',
|
||||
oninput: m.withAttr('value', function(value) {
|
||||
user.current.old_password = value
|
||||
})
|
||||
}),
|
||||
m('input.third#rNPwd', {
|
||||
type: 'password',
|
||||
required: 'required',
|
||||
style: userProfile.changePassword ?
|
||||
'display: inline-block;'
|
||||
: 'display: none;',
|
||||
placeholder: 'Ulang Password Baru',
|
||||
oninput: m.withAttr('value', function(value) {
|
||||
user.current.re_new_password = value
|
||||
})
|
||||
})
|
||||
])
|
||||
]),
|
||||
m('tr', [
|
||||
m('td', 'Hak Akses'),
|
||||
m('td', ':'),
|
||||
m('td', user.current.privilege == 1 ? 'Admin' : 'User')
|
||||
]),
|
||||
m('tr', [
|
||||
m('td', 'Registrasi'),
|
||||
m('td', ':'),
|
||||
m('td', fecha.format(new Date(user.current.registered_at), 'YYYY-MM-DD'))
|
||||
])
|
||||
]),
|
||||
m('button.full.pseudo', {
|
||||
type: 'submit',
|
||||
}, [
|
||||
m('i.fa.fa-check-square-o', {
|
||||
'aria-hidden': 'true'
|
||||
}),
|
||||
m('span', {
|
||||
style: 'font-size: smaller;'
|
||||
}, ' Simpan')
|
||||
])
|
||||
])
|
||||
]))
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = userProfile
|
||||
Reference in New Issue
Block a user