0
1
Fork 0
This commit is contained in:
Juan Ferrer 2022-05-26 10:00:19 +02:00
parent 614038470d
commit f80e8b4476
7 changed files with 75 additions and 64 deletions

View File

@ -5,8 +5,9 @@
<db-form id="userForm">
<db-model property="model">
<custom>
SELECT u.id, u.nickname, u.email, c.phone
FROM account.user u
SELECT u.id, u.name user, u.nickname, u.email, c.phone, r.name role
FROM account.user u
JOIN account.role r ON r.id = u.role
LEFT JOIN vn.client c ON c.id = u.id
WHERE u.id = #user
</custom>
@ -24,10 +25,11 @@
<div id="form" class="access-log">
<div class="box vn-w-xs vn-pa-lg">
<div class="form">
<p>#{{$.userForm.id}}</p>
<p>{{$.userForm.nickname}}</p>
<p>{{$.userForm.email}}</p>
<p>{{$.userForm.phone}}</p>
<h4><htk-text form="user-form" column="nickname"/></h4>
<p>#<htk-text form="user-form" column="id"/> - <htk-text form="user-form" column="user"/></p>
<p><htk-text form="user-form" column="role"/></p>
<p><htk-text form="user-form" column="email"/></p>
<p><htk-text form="user-form" column="phone"/></p>
</div>
</div>
<htk-repeater form-id="iter" class="box vn-w-xs htk-list vn-mt-md">

View File

@ -295,10 +295,8 @@ Vn.Filter = new Class({
Extends: Htk.Field
,Tag: 'vn-filter'
,Child: 'model'
,Properties:
{
model:
{
,Properties: {
model: {
type: Db.Model
,set: function(x) {
x.batch = this._batch;
@ -309,8 +307,7 @@ Vn.Filter = new Class({
return this._model;
}
},
placeholder:
{
placeholder: {
type: String
,set: function(x) {
this._select.placeholder = x;
@ -320,8 +317,7 @@ Vn.Filter = new Class({
return this._placeholder;
}
},
filter:
{
filter: {
type: Sql.Filter
,set: function(x) {
this._filter = x;
@ -330,7 +326,7 @@ Vn.Filter = new Class({
,get: function() {
return this._filter;
}
},
}
}
,_valueColumnIndex: 0
@ -432,18 +428,24 @@ Vn.Filter = new Class({
if (!this._label)
return;
var row = -1;
let row = -1;
const model = this._model;
if (this._model.ready)
row = this._model.searchByIndex(this._valueColumnIndex, this._value);
if (model) {
if (this._model.ready)
row = model.searchByIndex(this._valueColumnIndex, this._value);
if (row != -1) {
var label = this._model.getByIndex(row, this._showColumnIndex);
this._label.nodeValue = label;
this._emptyLabel = false;
if (row != -1) {
var label = model.getByIndex(row, this._showColumnIndex);
this._label.nodeValue = label;
this._emptyLabel = false;
} else {
this._emptyLabel = true;
this._label.nodeValue = _('Loading...');
}
} else {
this._emptyLabel = true;
this._label.nodeValue = _('Loading...');
this._label.nodeValue = '';
}
}
});

View File

@ -62,38 +62,42 @@ module.exports = new Class({
}
,_onConnError: function(conn, error) {
if (error instanceof Vn.JsonException)
switch (error.exception) {
case 'BadLogin':
Htk.Toast.showError(_('Invalid login'));
this._logout();
break;
case 'Forbidden':
Htk.Toast.showError(_('You don\'t have enough privileges'));
break;
case 'UserDisabled':
Htk.Toast.showError(_('User disabled'));
this._logout();
break;
case 'SessionExpired':
Htk.Toast.showError(_('Session expired'));
this._logout();
break;
case 'OutdatedVersion':
this._newVersion(error);
break;
default:
if (error instanceof Vn.JsonException) {
if (error.message)
Htk.Toast.showError(error.message);
} else if (error.statusCode)
switch (error.statusCode) {
else
switch (error.exception) {
case 'BadLogin':
Htk.Toast.showError(_('Invalid login'));
this._logout();
break;
case 'Forbidden':
Htk.Toast.showError(_('You don\'t have enough privileges'));
break;
case 'UserDisabled':
Htk.Toast.showError(_('User disabled'));
this._logout();
break;
case 'SessionExpired':
Htk.Toast.showError(_('Session expired'));
this._logout();
break;
case 'OutdatedVersion':
this._newVersion(error);
break;
default:
Htk.Toast.showError(error.message);
}
} else if (error.statusCode) {
switch (error.statusCode) {
case 401:
Htk.Toast.showError(_('Invalid login'));
this._logout();
break;
default:
Htk.Toast.showError(error.message);
}
else {
}
} else {
console.error(error);
this._notifyError(error);
}

View File

@ -477,9 +477,8 @@ module.exports = new Class({
this._onUserSupplant.bind(this, callback, user));
}
,_onUserSupplant: function(callback, user, supplantOk) {
if (!supplantOk)
return;
,_onUserSupplant: function(callback, user, supplantOk, err) {
if (err) throw err;
sessionStorage.setItem('supplantUser', user);
this.loadMenu();

View File

@ -1,6 +1,9 @@
@import "../htk/style/classes";
$side-panel-width: 250px;
$navbar-height: 64px;
.vn-gui {
height: inherit;
@ -16,12 +19,12 @@
.navbar {
position: fixed;
background-color: #1A1A1A;
left: 250px;
left: $side-panel-width;
top: 0;
right: 0;
z-index: 1;
overflow: hidden;
height: 64px;
height: $navbar-height;
color: white;
display: flex;
align-items: center;
@ -48,17 +51,18 @@
align-items: center;
gap: 15px;
overflow: hidden;
padding-left: 15px;
& > .title {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
h1 {
font-weight: normal;
font-size: 1.4em;
padding-left: 8px;
margin: 0;
white-space: nowrap;
text-overflow: ellipsis;
overflow: hidden;
}
}
}
@ -122,7 +126,7 @@
top: 0;
background-color: white;
z-index: 20;
width: 250px;
width: $side-panel-width;
}
.menu-overflow {
position: absolute;
@ -135,7 +139,7 @@
.menu-header {
background-color: #1A1A1A;
color: white;
height: 64px;
height: $navbar-height;
display: flex;
}
.logo {
@ -269,8 +273,8 @@
/* Body */
& > .body {
margin-left: 250px;
padding-top: 4.4em;
margin-left: $side-panel-width;
padding-top: $navbar-height;
height: inherit;
box-sizing: border-box;
height: inherit;

View File

@ -230,6 +230,7 @@ td.cell-image .htk-image {
margin: .1em 0;
text-overflow: ellipsis;
white-space: nowrap;
overflow: hidden;
}
}
& > .actions {

View File

@ -116,12 +116,12 @@ module.exports = new Class({
this._onUserSupplant.bind(this, callback));
}
,_onUserSupplant: function(callback, json) {
,_onUserSupplant: function(callback, json, err) {
if (json)
this.token = json;
if (callback)
callback(json != null);
callback(err == null, err);
}
/**
@ -302,7 +302,6 @@ module.exports = new Class({
data = null;
error = e;
}
if (callback)
try {
callback(data, error);
@ -314,7 +313,7 @@ module.exports = new Class({
if (error) {
if (error.exception == 'SessionExpired')
this.clearToken();
this.signalEmit('error', error);
}
}