New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[O2B-504] Create tag and add email and mattermost #547
Changes from all commits
1d3ea80
ba06b71
d146630
74c8e81
9c61b38
d445d72
b6ac182
41e812c
182c65c
8c86481
485745d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,9 +21,8 @@ import errorAlert from '../../../components/common/errorAlert.js'; | |
* @return {vnode} Return the view of the inputs | ||
*/ | ||
const createTagScreen = (model) => { | ||
const text = model.tags.getText(); | ||
const data = model.tags.getCreatedTag(); | ||
|
||
const { email, mattermost, text } = model.tags; | ||
const disabled = text.length < 3 || text.length > 20 || data.isLoading(); | ||
|
||
return h('div#create-tag', [ | ||
|
@@ -40,9 +39,31 @@ const createTagScreen = (model) => { | |
minlength: 3, | ||
maxlength: 20, | ||
value: text, | ||
oninput: (e) => model.tags.setText(e.target.value), | ||
oninput: (e) => { | ||
model.tags.text = e.target.value; | ||
}, | ||
}, text), | ||
model.isAdmin() && [ | ||
h('label.f4.mt3.mb1', 'Tags should inform below channels and groups on log creation:'), | ||
h('label.f5.mb2', 'For multiple fields split by comma seperation'), | ||
h('label.form-check-label.f4.mt2', { for: 'mattermost' }, 'Mattermost channels'), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could we add a descriptive label above "Mattermost" and "Email" Fields so that is clear to the users what are their tags going to do. Something similar to:
|
||
h('input#mattermost.form-control.w-25.mb2', { | ||
placeholder: 'Enter the mattermost channels..', | ||
value: mattermost, | ||
oninput: (e) => { | ||
model.tags.mattermost = e.target.value; | ||
}, | ||
}, mattermost), | ||
|
||
h('label.form-check-label.f4.mt2', { for: 'email' }, 'Email lists'), | ||
h('input#email.form-control.w-25.mb2', { | ||
placeholder: 'Enter the email groups...', | ||
value: email, | ||
oninput: (e) =>{ | ||
model.tags.email = e.target.value; | ||
}, | ||
}, email), | ||
], | ||
h('button.shadow-level1.btn.btn-success.mt2#send', { | ||
disabled, | ||
onclick: () => model.tags.createTag(), | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -71,8 +71,26 @@ class TagModel extends Observable { | |
* | ||
* @returns {String} The text currently inserted in the tag creation screen. | ||
*/ | ||
getText() { | ||
return this.text; | ||
get text() { | ||
return this._text; | ||
} | ||
|
||
/** | ||
* Getter for email | ||
* | ||
* @returns {String} The text currently inserted in the tag creation screen. | ||
*/ | ||
get email() { | ||
return this._email; | ||
} | ||
|
||
/** | ||
* Getter for mattermost | ||
* | ||
* @returns {String} The text currently inserted in the tag creation screen. | ||
*/ | ||
get mattermost() { | ||
return this._mattermost; | ||
} | ||
|
||
/** | ||
|
@@ -217,15 +235,16 @@ class TagModel extends Observable { | |
async createTag() { | ||
this.createdTag = RemoteData.loading(); | ||
this.notify(); | ||
|
||
const response = await fetchClient('/api/tags', { | ||
method: 'POST', | ||
headers: { | ||
Accept: 'application/json', | ||
'Content-Type': 'application/json', | ||
}, | ||
body: JSON.stringify({ | ||
text: this.getText(), | ||
text: this._text, | ||
mattermost: this.model.isAdmin() && this._mattermost ? this._mattermost : null, | ||
email: this.model.isAdmin() && this._email ? this._email : null, | ||
}), | ||
}); | ||
const result = await response.json(); | ||
|
@@ -245,8 +264,30 @@ class TagModel extends Observable { | |
* @param {String} text The newly inserted text. | ||
* @returns {undefined} | ||
*/ | ||
setText(text) { | ||
this.text = text; | ||
set text(text) { | ||
this._text = text; | ||
this.notify(); | ||
} | ||
|
||
/** | ||
* Setter for email | ||
* | ||
* @param {String} email The newly inserted email. | ||
* @returns {undefined} | ||
*/ | ||
set email(email) { | ||
this._email = email; | ||
this.notify(); | ||
} | ||
|
||
/** | ||
* Setter for mattermost. | ||
* | ||
* @param {String} mattermost The newly inserted mattermost groups. | ||
* @returns {undefined} | ||
*/ | ||
set mattermost(mattermost) { | ||
this._mattermost = mattermost; | ||
this.notify(); | ||
} | ||
|
||
|
@@ -292,8 +333,11 @@ class TagModel extends Observable { | |
* @returns {undefined} | ||
*/ | ||
clearEditor() { | ||
this.text = ''; | ||
this._text = ''; | ||
this._mattermost = '', | ||
this._email = '', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As we change the state we should also notify about it, especially as one of the objects is a RemoteData one |
||
this.createdTag = RemoteData.NotAsked(); | ||
this.notify(); | ||
} | ||
|
||
/** | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you be able to also add the "Create Tag" restriction? `Text/Description of tag should limit input to letters and characters '_ + '