Browse Source

adding

master
HerrHase 3 years ago
parent
commit
d95c93bbc2
10 changed files with 191 additions and 83 deletions
  1. +36
    -16
      public/js/bucket-single.js
  2. +7
    -7
      public/js/create-bucket.js
  3. +14
    -14
      public/js/dashboard.js
  4. +85
    -39
      public/js/users.js
  5. +18
    -0
      resources/js/FormValidator.js
  6. +1
    -1
      resources/js/components/field-error.riot
  7. +0
    -0
      resources/js/components/loading.riot
  8. +7
    -0
      resources/js/components/users.riot
  9. +22
    -4
      resources/js/components/users/form.riot
  10. +1
    -2
      src/http/api/users.ts

+ 36
- 16
public/js/bucket-single.js View File

@ -52,7 +52,7 @@ __webpack_require__.r(__webpack_exports__);
const parent = this.root.closest(state.closest) const parent = this.root.closest(state.closest)
// getting current element by name // getting current element by name
const element = document.querySelector('[name="' + props.name + '"]')
const element = parent.querySelector('[name="' + props.name + '"]')
// getting form // getting form
const form = element.closest('form') const form = element.closest('form')
@ -124,7 +124,7 @@ __webpack_require__.r(__webpack_exports__);
getComponent getComponent
) { ) {
return template( return template(
'<div expr15="expr15" class="field-error"></div>',
'<div expr3="expr3" class="field-error"></div>',
[ [
{ {
'type': bindingTypes.IF, 'type': bindingTypes.IF,
@ -135,11 +135,11 @@ __webpack_require__.r(__webpack_exports__);
return _scope.state.errors.length > 0; return _scope.state.errors.length > 0;
}, },
'redundantAttribute': 'expr15',
'selector': '[expr15]',
'redundantAttribute': 'expr3',
'selector': '[expr3]',
'template': template( 'template': template(
'<ul><li expr16="expr16"></li></ul>',
'<ul><li expr4="expr4"></li></ul>',
[ [
{ {
'type': bindingTypes.EACH, 'type': bindingTypes.EACH,
@ -170,8 +170,8 @@ __webpack_require__.r(__webpack_exports__);
] ]
), ),
'redundantAttribute': 'expr16',
'selector': '[expr16]',
'redundantAttribute': 'expr4',
'selector': '[expr4]',
'itemName': 'error', 'itemName': 'error',
'indexName': null, 'indexName': null,
@ -289,7 +289,7 @@ riot__WEBPACK_IMPORTED_MODULE_3__.mount('field-error')
getComponent getComponent
) { ) {
return template( return template(
'<div class="note-form"><div class="panel"><div class="panel__body"><form id="form" novalidate><input expr17="expr17" type="hidden" name="_id"/><div class="field-group"><label class="field-label">\n title\n <input type="text" class="field-text" name="title"/></label></div><div class="field-group"><label class="field-label">\n content\n <textarea name="content" class="field-text"></textarea></label></div><div class><div class="tabs"></div></div><div><button expr18="expr18" class="button"></button><button expr19="expr19" class="button" type="submit"></button></div></form></div></div></div>',
'<div class="note-form"><div class="panel"><div class="panel__body"><form id="form" novalidate><input expr0="expr0" type="hidden" name="_id"/><div class="field-group"><label class="field-label">\n title\n <input type="text" class="field-text" name="title"/></label></div><div class="field-group"><label class="field-label">\n content\n <textarea name="content" class="field-text"></textarea></label></div><div class><div class="tabs"></div></div><div><button expr1="expr1" class="button"></button><button expr2="expr2" class="button" type="submit"></button></div></form></div></div></div>',
[ [
{ {
'type': bindingTypes.IF, 'type': bindingTypes.IF,
@ -300,8 +300,8 @@ riot__WEBPACK_IMPORTED_MODULE_3__.mount('field-error')
return _scope.state.note && _scope.state.note._id; return _scope.state.note && _scope.state.note._id;
}, },
'redundantAttribute': 'expr17',
'selector': '[expr17]',
'redundantAttribute': 'expr0',
'selector': '[expr0]',
'template': template( 'template': template(
null, null,
@ -332,8 +332,8 @@ riot__WEBPACK_IMPORTED_MODULE_3__.mount('field-error')
return !_scope.state.note || (_scope.state.note && !_scope.state.note._id); return !_scope.state.note || (_scope.state.note && !_scope.state.note._id);
}, },
'redundantAttribute': 'expr18',
'selector': '[expr18]',
'redundantAttribute': 'expr1',
'selector': '[expr1]',
'template': template( 'template': template(
'\n Create\n ', '\n Create\n ',
@ -349,8 +349,8 @@ riot__WEBPACK_IMPORTED_MODULE_3__.mount('field-error')
return _scope.state.note && _scope.state.note._id; return _scope.state.note && _scope.state.note._id;
}, },
'redundantAttribute': 'expr19',
'selector': '[expr19]',
'redundantAttribute': 'expr2',
'selector': '[expr2]',
'template': template( 'template': template(
'\n Save\n ', '\n Save\n ',
@ -2265,12 +2265,32 @@ var FormValidator = /*#__PURE__*/function () {
} }
/** /**
* *
* @param {[type]} event [description]
* @return {[type]} [description]
*
*/ */
_createClass(FormValidator, [{ _createClass(FormValidator, [{
key: "setConstraits",
value: function setConstraits(constraits) {
this.constraits = constraits;
}
/**
*
*
*/
}, {
key: "getConstraits",
value: function getConstraits(constraits) {
return this.constraits;
}
/**
*
* @param {[type]} event [description]
* @return {[type]} [description]
*/
}, {
key: "onSubmit", key: "onSubmit",
value: function onSubmit(event) { value: function onSubmit(event) {
var _this2 = this; var _this2 = this;


+ 7
- 7
public/js/create-bucket.js View File

@ -52,7 +52,7 @@ __webpack_require__.r(__webpack_exports__);
const parent = this.root.closest(state.closest) const parent = this.root.closest(state.closest)
// getting current element by name // getting current element by name
const element = document.querySelector('[name="' + props.name + '"]')
const element = parent.querySelector('[name="' + props.name + '"]')
// getting form // getting form
const form = element.closest('form') const form = element.closest('form')
@ -124,7 +124,7 @@ __webpack_require__.r(__webpack_exports__);
getComponent getComponent
) { ) {
return template( return template(
'<div expr15="expr15" class="field-error"></div>',
'<div expr3="expr3" class="field-error"></div>',
[ [
{ {
'type': bindingTypes.IF, 'type': bindingTypes.IF,
@ -135,11 +135,11 @@ __webpack_require__.r(__webpack_exports__);
return _scope.state.errors.length > 0; return _scope.state.errors.length > 0;
}, },
'redundantAttribute': 'expr15',
'selector': '[expr15]',
'redundantAttribute': 'expr3',
'selector': '[expr3]',
'template': template( 'template': template(
'<ul><li expr16="expr16"></li></ul>',
'<ul><li expr4="expr4"></li></ul>',
[ [
{ {
'type': bindingTypes.EACH, 'type': bindingTypes.EACH,
@ -170,8 +170,8 @@ __webpack_require__.r(__webpack_exports__);
] ]
), ),
'redundantAttribute': 'expr16',
'selector': '[expr16]',
'redundantAttribute': 'expr4',
'selector': '[expr4]',
'itemName': 'error', 'itemName': 'error',
'indexName': null, 'indexName': null,


+ 14
- 14
public/js/dashboard.js View File

@ -74,7 +74,7 @@ __webpack_require__.r(__webpack_exports__);
getComponent getComponent
) { ) {
return template( return template(
'<div class="buckets"><div class="grid"><div expr0="expr0" class="col-12 col-md-4 col-xlg-3"></div></div><div class="grid"><div class="col-12"><div class="buckets__more"><button expr5="expr5" type="button" class="button">\n More\n <svg class="icon" aria-hidden="true"><use xlink:href="/symbol-defs.svg#icon-arrow-down"/></svg></button></div></div></div></div>',
'<div class="buckets"><div class="grid"><div expr16="expr16" class="col-12 col-md-4 col-xlg-3"></div></div><div class="grid"><div class="col-12"><div class="buckets__more"><button expr21="expr21" type="button" class="button">\n More\n <svg class="icon" aria-hidden="true"><use xlink:href="/symbol-defs.svg#icon-arrow-down"/></svg></button></div></div></div></div>',
[ [
{ {
'type': bindingTypes.EACH, 'type': bindingTypes.EACH,
@ -82,11 +82,11 @@ __webpack_require__.r(__webpack_exports__);
'condition': null, 'condition': null,
'template': template( 'template': template(
'<article class="panel buckets__item"><div class="bar"><div class="bar__end w-100"><button expr1="expr1" class="button button--transparent"><svg class="icon fill-text-contrast" aria-hidden="true"><use xlink:href="/symbol-defs.svg#icon-delete"/></svg></button></div></div><div class="panel__body"><a expr2="expr2"><h3 expr3="expr3" class="buckets__title"> </h3><div class="content"><p expr4="expr4"> </p></div></a></div></article>',
'<article class="panel buckets__item"><div class="bar"><div class="bar__end w-100"><button expr17="expr17" class="button button--transparent"><svg class="icon fill-text-contrast" aria-hidden="true"><use xlink:href="/symbol-defs.svg#icon-delete"/></svg></button></div></div><div class="panel__body"><a expr18="expr18"><h3 expr19="expr19" class="buckets__title"> </h3><div class="content"><p expr20="expr20"> </p></div></a></div></article>',
[ [
{ {
'redundantAttribute': 'expr1',
'selector': '[expr1]',
'redundantAttribute': 'expr17',
'selector': '[expr17]',
'expressions': [ 'expressions': [
{ {
@ -102,8 +102,8 @@ __webpack_require__.r(__webpack_exports__);
] ]
}, },
{ {
'redundantAttribute': 'expr2',
'selector': '[expr2]',
'redundantAttribute': 'expr18',
'selector': '[expr18]',
'expressions': [ 'expressions': [
{ {
@ -124,8 +124,8 @@ __webpack_require__.r(__webpack_exports__);
] ]
}, },
{ {
'redundantAttribute': 'expr3',
'selector': '[expr3]',
'redundantAttribute': 'expr19',
'selector': '[expr19]',
'expressions': [ 'expressions': [
{ {
@ -145,8 +145,8 @@ __webpack_require__.r(__webpack_exports__);
] ]
}, },
{ {
'redundantAttribute': 'expr4',
'selector': '[expr4]',
'redundantAttribute': 'expr20',
'selector': '[expr20]',
'expressions': [ 'expressions': [
{ {
@ -168,8 +168,8 @@ __webpack_require__.r(__webpack_exports__);
] ]
), ),
'redundantAttribute': 'expr0',
'selector': '[expr0]',
'redundantAttribute': 'expr16',
'selector': '[expr16]',
'itemName': 'bucket', 'itemName': 'bucket',
'indexName': null, 'indexName': null,
@ -180,8 +180,8 @@ __webpack_require__.r(__webpack_exports__);
} }
}, },
{ {
'redundantAttribute': 'expr5',
'selector': '[expr5]',
'redundantAttribute': 'expr21',
'selector': '[expr21]',
'expressions': [ 'expressions': [
{ {


+ 85
- 39
public/js/users.js View File

@ -52,7 +52,7 @@ __webpack_require__.r(__webpack_exports__);
const parent = this.root.closest(state.closest) const parent = this.root.closest(state.closest)
// getting current element by name // getting current element by name
const element = document.querySelector('[name="' + props.name + '"]')
const element = parent.querySelector('[name="' + props.name + '"]')
// getting form // getting form
const form = element.closest('form') const form = element.closest('form')
@ -124,7 +124,7 @@ __webpack_require__.r(__webpack_exports__);
getComponent getComponent
) { ) {
return template( return template(
'<div expr15="expr15" class="field-error"></div>',
'<div expr3="expr3" class="field-error"></div>',
[ [
{ {
'type': bindingTypes.IF, 'type': bindingTypes.IF,
@ -135,11 +135,11 @@ __webpack_require__.r(__webpack_exports__);
return _scope.state.errors.length > 0; return _scope.state.errors.length > 0;
}, },
'redundantAttribute': 'expr15',
'selector': '[expr15]',
'redundantAttribute': 'expr3',
'selector': '[expr3]',
'template': template( 'template': template(
'<ul><li expr16="expr16"></li></ul>',
'<ul><li expr4="expr4"></li></ul>',
[ [
{ {
'type': bindingTypes.EACH, 'type': bindingTypes.EACH,
@ -170,8 +170,8 @@ __webpack_require__.r(__webpack_exports__);
] ]
), ),
'redundantAttribute': 'expr16',
'selector': '[expr16]',
'redundantAttribute': 'expr4',
'selector': '[expr4]',
'itemName': 'error', 'itemName': 'error',
'indexName': null, 'indexName': null,
@ -421,11 +421,11 @@ __webpack_require__.r(__webpack_exports__);
getComponent getComponent
) { ) {
return template( return template(
'<button expr20="expr20" class="button m-bottom-0" type="button"><slot expr21="expr21"></slot></button>',
'<button expr14="expr14" class="button m-bottom-0" type="button"><slot expr15="expr15"></slot></button>',
[ [
{ {
'redundantAttribute': 'expr20',
'selector': '[expr20]',
'redundantAttribute': 'expr14',
'selector': '[expr14]',
'expressions': [ 'expressions': [
{ {
@ -444,8 +444,8 @@ __webpack_require__.r(__webpack_exports__);
'type': bindingTypes.SLOT, 'type': bindingTypes.SLOT,
'attributes': [], 'attributes': [],
'name': 'default', 'name': 'default',
'redundantAttribute': 'expr21',
'selector': '[expr21]'
'redundantAttribute': 'expr15',
'selector': '[expr15]'
} }
] ]
); );
@ -495,6 +495,13 @@ riot__WEBPACK_IMPORTED_MODULE_3__.mount('app-modal')
this.fetch() this.fetch()
}, },
/**
*
* @param {[type]} event
* @param {[type]} user
* @return {[type]}
*
*/
handleUpdate(event, user) { handleUpdate(event, user) {
const customEvent = new CustomEvent('app-users-form-open', { const customEvent = new CustomEvent('app-users-form-open', {
'detail': user 'detail': user
@ -550,7 +557,7 @@ riot__WEBPACK_IMPORTED_MODULE_3__.mount('app-modal')
getComponent getComponent
) { ) {
return template( return template(
'<div class="buckets"><table class="table"><thead><tr class="table__tr"><th class="table__th">\n Email\n </th><th class="table__th">\n Display Name\n </th><th class="table__th" colspan="2">\n Roles\n </th></tr></thead><tbody><tr expr6="expr6" class="table__tr"></tr></tbody></table><app-modal expr12="expr12" id="user-delete-confirm"></app-modal><div expr13="expr13" class="grid"></div></div>',
'<div class="buckets"><table class="table"><thead><tr class="table__tr"><th class="table__th">\n Email\n </th><th class="table__th">\n Display Name\n </th><th class="table__th" colspan="2">\n Roles\n </th></tr></thead><tbody><tr expr5="expr5" class="table__tr"></tr></tbody></table><app-modal expr11="expr11" id="user-delete-confirm"></app-modal><div expr12="expr12" class="grid"></div></div>',
[ [
{ {
'type': bindingTypes.EACH, 'type': bindingTypes.EACH,
@ -558,11 +565,11 @@ riot__WEBPACK_IMPORTED_MODULE_3__.mount('app-modal')
'condition': null, 'condition': null,
'template': template( 'template': template(
'<td expr7="expr7" class="table__td"> </td><td expr8="expr8" class="table__td"> </td><td class="table__td"><div expr9="expr9"></div></td><td class="table__td right"><app-sidebar-button expr10="expr10" class="m-bottom-0 m-right-3" event="app-users-form-open" selector="app-users-form"></app-sidebar-button><button expr11="expr11" class="button button--small m-bottom-0" type="button"><svg class="icon" aria-hidden="true"><use xlink:href="/symbol-defs.svg#icon-delete"/></svg></button></td>',
'<td expr6="expr6" class="table__td"> </td><td expr7="expr7" class="table__td"> </td><td class="table__td"><div expr8="expr8"></div></td><td class="table__td right"><app-sidebar-button expr9="expr9" class="m-bottom-0 m-right-3" event="app-users-form-open" selector="app-users-form"></app-sidebar-button><button expr10="expr10" class="button button--small m-bottom-0" type="button"><svg class="icon" aria-hidden="true"><use xlink:href="/symbol-defs.svg#icon-delete"/></svg></button></td>',
[ [
{ {
'redundantAttribute': 'expr7',
'selector': '[expr7]',
'redundantAttribute': 'expr6',
'selector': '[expr6]',
'expressions': [ 'expressions': [
{ {
@ -582,8 +589,8 @@ riot__WEBPACK_IMPORTED_MODULE_3__.mount('app-modal')
] ]
}, },
{ {
'redundantAttribute': 'expr8',
'selector': '[expr8]',
'redundantAttribute': 'expr7',
'selector': '[expr7]',
'expressions': [ 'expressions': [
{ {
@ -611,8 +618,8 @@ riot__WEBPACK_IMPORTED_MODULE_3__.mount('app-modal')
return _scope.user.roles && _scope.user.roles.indexOf('admin') >= 0; return _scope.user.roles && _scope.user.roles.indexOf('admin') >= 0;
}, },
'redundantAttribute': 'expr9',
'selector': '[expr9]',
'redundantAttribute': 'expr8',
'selector': '[expr8]',
'template': template( 'template': template(
'\n Admin\n <svg class="icon" aria-hidden="true"><use xlink:href="/symbol-defs.svg#icon-check"/></svg>', '\n Admin\n <svg class="icon" aria-hidden="true"><use xlink:href="/symbol-defs.svg#icon-check"/></svg>',
@ -650,12 +657,12 @@ riot__WEBPACK_IMPORTED_MODULE_3__.mount('app-modal')
} }
], ],
'redundantAttribute': 'expr10',
'selector': '[expr10]'
'redundantAttribute': 'expr9',
'selector': '[expr9]'
}, },
{ {
'redundantAttribute': 'expr11',
'selector': '[expr11]',
'redundantAttribute': 'expr10',
'selector': '[expr10]',
'expressions': [ 'expressions': [
{ {
@ -673,8 +680,8 @@ riot__WEBPACK_IMPORTED_MODULE_3__.mount('app-modal')
] ]
), ),
'redundantAttribute': 'expr6',
'selector': '[expr6]',
'redundantAttribute': 'expr5',
'selector': '[expr5]',
'itemName': 'user', 'itemName': 'user',
'indexName': null, 'indexName': null,
@ -703,8 +710,8 @@ riot__WEBPACK_IMPORTED_MODULE_3__.mount('app-modal')
], ],
'attributes': [], 'attributes': [],
'redundantAttribute': 'expr12',
'selector': '[expr12]'
'redundantAttribute': 'expr11',
'selector': '[expr11]'
}, },
{ {
'type': bindingTypes.IF, 'type': bindingTypes.IF,
@ -715,15 +722,15 @@ riot__WEBPACK_IMPORTED_MODULE_3__.mount('app-modal')
return _scope.state.maxLength > _scope.state.users.length; return _scope.state.maxLength > _scope.state.users.length;
}, },
'redundantAttribute': 'expr13',
'selector': '[expr13]',
'redundantAttribute': 'expr12',
'selector': '[expr12]',
'template': template( 'template': template(
'<div class="col-12"><div class="buckets__more"><button expr14="expr14" type="button" class="button">\n More\n <svg class="icon" aria-hidden="true"><use xlink:href="/symbol-defs.svg#icon-arrow-down"/></svg></button></div></div>',
'<div class="col-12"><div class="buckets__more"><button expr13="expr13" type="button" class="button">\n More\n <svg class="icon" aria-hidden="true"><use xlink:href="/symbol-defs.svg#icon-arrow-down"/></svg></button></div></div>',
[ [
{ {
'redundantAttribute': 'expr14',
'selector': '[expr14]',
'redundantAttribute': 'expr13',
'selector': '[expr13]',
'expressions': [ 'expressions': [
{ {
@ -797,12 +804,22 @@ riot__WEBPACK_IMPORTED_MODULE_3__.mount('field-error')
// check for data, and if user is send add to state // check for data, and if user is send add to state
if (event.detail.data) { if (event.detail.data) {
this.state.user = event.detail.data this.state.user = event.detail.data
this.state.formValidation.setConstraits({
'email': {
'length': {
'maximum': 255
},
'email': true,
'presence': true
}
})
this.update() this.update()
} }
}) })
// create form validation // create form validation
const formValidation = new _FormValidator__WEBPACK_IMPORTED_MODULE_1__.default('#app-users-form', {
this.state.formValidation = new _FormValidator__WEBPACK_IMPORTED_MODULE_1__.default('#app-users-form', {
'email': { 'email': {
'length': { 'length': {
'maximum': 255 'maximum': 255
@ -844,18 +861,27 @@ riot__WEBPACK_IMPORTED_MODULE_3__.mount('field-error')
handleSubmit(event, data) { handleSubmit(event, data) {
let method = 'post' let method = 'post'
let url = '/api/users'
// user is set and has id, send as put with id
if (this.state.user && this.state.user._id) { if (this.state.user && this.state.user._id) {
method = 'put' method = 'put'
url += '/' + this.state.user._id
} }
axios__WEBPACK_IMPORTED_MODULE_0___default()({ axios__WEBPACK_IMPORTED_MODULE_0___default()({
method: method, method: method,
url: '/api/users',
url: url,
data: data data: data
}).then((response) => { }).then((response) => {
this.state.user = response.data.data this.state.user = response.data.data
this.$('#sidebar-user-form-close').click()
console.log(event)
if (event.submitter.attributes.close) {
this.$('#sidebar-user-form-close').click()
}
this.update() this.update()
}) })
@ -863,7 +889,7 @@ riot__WEBPACK_IMPORTED_MODULE_3__.mount('field-error')
/** /**
* *
*
*
*/ */
reset() { reset() {
this.state.user = { } this.state.user = { }
@ -2931,12 +2957,32 @@ var FormValidator = /*#__PURE__*/function () {
} }
/** /**
* *
* @param {[type]} event [description]
* @return {[type]} [description]
*
*/ */
_createClass(FormValidator, [{ _createClass(FormValidator, [{
key: "setConstraits",
value: function setConstraits(constraits) {
this.constraits = constraits;
}
/**
*
*
*/
}, {
key: "getConstraits",
value: function getConstraits(constraits) {
return this.constraits;
}
/**
*
* @param {[type]} event [description]
* @return {[type]} [description]
*/
}, {
key: "onSubmit", key: "onSubmit",
value: function onSubmit(event) { value: function onSubmit(event) {
var _this2 = this; var _this2 = this;


+ 18
- 0
resources/js/FormValidator.js View File

@ -45,6 +45,24 @@ class FormValidator
this.onSuccess = onSuccess this.onSuccess = onSuccess
} }
/**
*
*
*/
setConstraits(constraits)
{
this.constraits = constraits
}
/**
*
*
*/
getConstraits(constraits)
{
return this.constraits
}
/** /**
* *
* @param {[type]} event [description] * @param {[type]} event [description]


+ 1
- 1
resources/js/components/field-error.riot View File

@ -56,7 +56,7 @@
const parent = this.root.closest(state.closest) const parent = this.root.closest(state.closest)
// getting current element by name // getting current element by name
const element = document.querySelector('[name="' + props.name + '"]')
const element = parent.querySelector('[name="' + props.name + '"]')
// getting form // getting form
const form = element.closest('form') const form = element.closest('form')


+ 0
- 0
resources/js/components/loading.riot View File


+ 7
- 0
resources/js/components/users.riot View File

@ -104,6 +104,13 @@
this.fetch() this.fetch()
}, },
/**
*
* @param {[type]} event
* @param {[type]} user
* @return {[type]}
*
*/
handleUpdate(event, user) { handleUpdate(event, user) {
const customEvent = new CustomEvent('app-users-form-open', { const customEvent = new CustomEvent('app-users-form-open', {
'detail': user 'detail': user


+ 22
- 4
resources/js/components/users/form.riot View File

@ -107,12 +107,22 @@
// check for data, and if user is send add to state // check for data, and if user is send add to state
if (event.detail.data) { if (event.detail.data) {
this.state.user = event.detail.data this.state.user = event.detail.data
this.state.formValidation.setConstraits({
'email': {
'length': {
'maximum': 255
},
'email': true,
'presence': true
}
})
this.update() this.update()
} }
}) })
// create form validation // create form validation
const formValidation = new FormValidator('#app-users-form', {
this.state.formValidation = new FormValidator('#app-users-form', {
'email': { 'email': {
'length': { 'length': {
'maximum': 255 'maximum': 255
@ -154,18 +164,26 @@
handleSubmit(event, data) { handleSubmit(event, data) {
let method = 'post' let method = 'post'
let url = '/api/users'
// user is set and has id, send as put with id
if (this.state.user && this.state.user._id) { if (this.state.user && this.state.user._id) {
method = 'put' method = 'put'
url += '/' + this.state.user._id
} }
axios({ axios({
method: method, method: method,
url: '/api/users',
url: url,
data: data data: data
}).then((response) => { }).then((response) => {
this.state.user = response.data.data this.state.user = response.data.data
this.$('#sidebar-user-form-close').click()
// check if submit has close-attribute
if (event.submitter.attributes.close) {
this.$('#sidebar-user-form-close').click()
}
this.update() this.update()
}) })
@ -173,7 +191,7 @@
/** /**
* *
*
*
*/ */
reset() { reset() {
this.state.user = { } this.state.user = { }


+ 1
- 2
src/http/api/users.ts View File

@ -90,7 +90,7 @@ router.put('/:id', async function(request, response)
const [ valid, errors ] = await validate(body, { const [ valid, errors ] = await validate(body, {
email: [ isEmail, maxLength(255), required ], email: [ isEmail, maxLength(255), required ],
password: [ required, maxLength(64) ]
password: [ maxLength(64) ]
}) })
if (valid) { if (valid) {
@ -121,7 +121,6 @@ router.delete('/:id', async function(request, response)
const userRepository = new UserRepository() const userRepository = new UserRepository()
// @TODO check for permission of current user // @TODO check for permission of current user
let user = false let user = false
const [ valid, errors ] = await validate(request.params, { const [ valid, errors ] = await validate(request.params, {


Loading…
Cancel
Save