#148 client web-access task
This commit is contained in:
parent
1e48f4a4a9
commit
6eaaa6dde5
|
@ -19,11 +19,11 @@
|
|||
</vn-horizontal>
|
||||
<vn-horizontal>
|
||||
<vn-textfield
|
||||
vn-focus
|
||||
vn-one
|
||||
margin-medium-top
|
||||
label="User"
|
||||
field="$ctrl.account.name"
|
||||
vn-focus>
|
||||
field="$ctrl.account.name">
|
||||
</vn-textfield>
|
||||
</vn-horizontal>
|
||||
</vn-card>
|
||||
|
@ -49,7 +49,7 @@
|
|||
</vn-textfield>
|
||||
</tpl-body>
|
||||
<tpl-buttons>
|
||||
<button response="CANCEL" translate>Cancel</button>
|
||||
<input type="button" response="CANCEL" translate-attr="{value: 'Cancel'}"/>
|
||||
<button response="ACCEPT" translate>Change password</button>
|
||||
</tpl-buttons>
|
||||
</vn-dialog>
|
||||
|
|
|
@ -18,17 +18,15 @@ export default class Controller {
|
|||
}
|
||||
|
||||
isCustomer() {
|
||||
if (this.client && this.client.id) {
|
||||
if (this.client.id) {
|
||||
this.$http.get(`/client/api/Clients/${this.client.id}/hasCustomerRole`).then(res => {
|
||||
this.canChangePassword = (res.data) ? res.data.isCustomer : false;
|
||||
this.canChangePassword = res.data && res.data.isCustomer;
|
||||
});
|
||||
} else {
|
||||
this.canChangePassword = false;
|
||||
}
|
||||
}
|
||||
|
||||
checkConditions() {
|
||||
if (this.client && this.client.id) {
|
||||
if (this.client.id) {
|
||||
this.$http.get(`/client/api/Clients/${this.client.id}/isValidClient`).then(res => {
|
||||
this.canEnableCheckBox = res.data;
|
||||
});
|
||||
|
@ -42,7 +40,7 @@ export default class Controller {
|
|||
}
|
||||
|
||||
onPassChange(response) {
|
||||
if (response == 'ACCEPT' && this.canChangePassword)
|
||||
if (response == 'ACCEPT')
|
||||
try {
|
||||
if (!this.newPassword)
|
||||
throw new Error(`Passwords can't be empty`);
|
||||
|
|
|
@ -37,14 +37,16 @@ export default class Dialog extends Component {
|
|||
show() {
|
||||
if (this.shown) return;
|
||||
this.shown = true;
|
||||
this.keypressHandler = e => this.onKeypress(e);
|
||||
this.document.addEventListener('keypress', this.keypressHandler);
|
||||
this.keyDownHandler = e => this.onkeyDown(e);
|
||||
this.document.addEventListener('keydown', this.keyDownHandler);
|
||||
this.element.style.display = 'flex';
|
||||
this.transitionTimeout =
|
||||
setTimeout(() => this.$element.addClass('shown'), 30);
|
||||
this.transitionTimeout = setTimeout(() => this.$element.addClass('shown'), 30);
|
||||
|
||||
if (this.onOpen)
|
||||
this.onOpen();
|
||||
|
||||
let firstFocusable = this.element.querySelector('input, textarea');
|
||||
if (firstFocusable) firstFocusable.focus();
|
||||
}
|
||||
/**
|
||||
* Hides the dialog calling the response handler.
|
||||
|
@ -68,7 +70,7 @@ export default class Dialog extends Component {
|
|||
realHide() {
|
||||
if (!this.shown) return;
|
||||
this.element.style.display = 'none';
|
||||
this.document.removeEventListener('keypress', this.keypressHandler);
|
||||
this.document.removeEventListener('keydown', this.keyDownHandler);
|
||||
this.lastEvent = null;
|
||||
this.shown = false;
|
||||
this.transitionTimeout =
|
||||
|
@ -94,7 +96,7 @@ export default class Dialog extends Component {
|
|||
if (event != this.lastEvent)
|
||||
this.hide();
|
||||
}
|
||||
onKeypress(event) {
|
||||
onkeyDown(event) {
|
||||
if (event.keyCode == 27) // Esc
|
||||
this.hide();
|
||||
}
|
||||
|
|
|
@ -28,7 +28,10 @@
|
|||
display: block;
|
||||
width: 20em;
|
||||
}
|
||||
button {
|
||||
button,
|
||||
input[type="button"],
|
||||
input[type="submit"],
|
||||
input[type="reset"] {
|
||||
text-transform: uppercase;
|
||||
background-color: transparent;
|
||||
border: none;
|
||||
|
@ -55,7 +58,10 @@
|
|||
margin-top: 1.5em;
|
||||
text-align: right;
|
||||
|
||||
button {
|
||||
button,
|
||||
input[type="button"],
|
||||
input[type="submit"],
|
||||
input[type="reset"] {
|
||||
color: #ffa410;
|
||||
font-family: vn-font-bold;
|
||||
padding: .7em;
|
||||
|
|
|
@ -15,6 +15,7 @@ export default class Controller extends Component {
|
|||
this.button = $element[0].querySelector('button');
|
||||
this.textNode = this.snackbar.querySelector('.text');
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows a notification.
|
||||
*
|
||||
|
@ -29,14 +30,13 @@ export default class Controller extends Component {
|
|||
this.button.textContent =
|
||||
data.actionText || this.$translate.instant('Hide');
|
||||
|
||||
this.documentClickHandler = e => this.onDocumentClick(e);
|
||||
document.addEventListener('click', this.documentClickHandler);
|
||||
this.timeoutId = setTimeout(() => this.hide(),
|
||||
data.timeout || 6000);
|
||||
this.timeoutId = setTimeout(() =>
|
||||
this.hide(), data.timeout || 6000);
|
||||
|
||||
this.transitionTimeout =
|
||||
setTimeout(() => this.$snackbar.addClass('shown'), 30);
|
||||
this.transitionTimeout = setTimeout(() =>
|
||||
this.$snackbar.addClass('shown'), 30);
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows an error.
|
||||
*
|
||||
|
@ -46,38 +46,38 @@ export default class Controller extends Component {
|
|||
this.$snackbar.addClass('error');
|
||||
this.show(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Hides the snackbar.
|
||||
*/
|
||||
hide() {
|
||||
if (!this.shown) return;
|
||||
clearTimeout(this.timeoutId);
|
||||
document.removeEventListener('click', this.documentClickHandler);
|
||||
this.shown = false;
|
||||
this.hideTimeout = setTimeout(() => this.onTransitionEnd(), 250);
|
||||
|
||||
this.transitionTimeout =
|
||||
setTimeout(() => this.$snackbar.removeClass('shown'), 30);
|
||||
}
|
||||
|
||||
onTransitionEnd() {
|
||||
this.$snackbar.removeClass('error');
|
||||
this.textNode.textContent = '';
|
||||
this.button.textContent = '';
|
||||
this.actionHandler = null;
|
||||
}
|
||||
onDocumentClick(event) {
|
||||
if (event === this.event) return;
|
||||
this.hide();
|
||||
}
|
||||
|
||||
onSnackbarClick(event) {
|
||||
this.event = event;
|
||||
}
|
||||
|
||||
onButtonClick() {
|
||||
if (this.actionHandler)
|
||||
this.actionHandler();
|
||||
else
|
||||
this.hide();
|
||||
}
|
||||
|
||||
clearTimeouts() {
|
||||
clearTimeout(this.timeoutId);
|
||||
clearTimeout(this.hideTimeout);
|
||||
|
@ -86,6 +86,7 @@ export default class Controller extends Component {
|
|||
this.hideTimeout = null;
|
||||
this.transitionTimeout = null;
|
||||
}
|
||||
|
||||
$onDestroy() {
|
||||
this.clearTimeouts();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue