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-form id="userForm">
<db-model property="model"> <db-model property="model">
<custom> <custom>
SELECT u.id, u.nickname, u.email, c.phone SELECT u.id, u.name user, u.nickname, u.email, c.phone, r.name role
FROM account.user u FROM account.user u
JOIN account.role r ON r.id = u.role
LEFT JOIN vn.client c ON c.id = u.id LEFT JOIN vn.client c ON c.id = u.id
WHERE u.id = #user WHERE u.id = #user
</custom> </custom>
@ -24,10 +25,11 @@
<div id="form" class="access-log"> <div id="form" class="access-log">
<div class="box vn-w-xs vn-pa-lg"> <div class="box vn-w-xs vn-pa-lg">
<div class="form"> <div class="form">
<p>#{{$.userForm.id}}</p> <h4><htk-text form="user-form" column="nickname"/></h4>
<p>{{$.userForm.nickname}}</p> <p>#<htk-text form="user-form" column="id"/> - <htk-text form="user-form" column="user"/></p>
<p>{{$.userForm.email}}</p> <p><htk-text form="user-form" column="role"/></p>
<p>{{$.userForm.phone}}</p> <p><htk-text form="user-form" column="email"/></p>
<p><htk-text form="user-form" column="phone"/></p>
</div> </div>
</div> </div>
<htk-repeater form-id="iter" class="box vn-w-xs htk-list vn-mt-md"> <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 Extends: Htk.Field
,Tag: 'vn-filter' ,Tag: 'vn-filter'
,Child: 'model' ,Child: 'model'
,Properties: ,Properties: {
{ model: {
model:
{
type: Db.Model type: Db.Model
,set: function(x) { ,set: function(x) {
x.batch = this._batch; x.batch = this._batch;
@ -309,8 +307,7 @@ Vn.Filter = new Class({
return this._model; return this._model;
} }
}, },
placeholder: placeholder: {
{
type: String type: String
,set: function(x) { ,set: function(x) {
this._select.placeholder = x; this._select.placeholder = x;
@ -320,8 +317,7 @@ Vn.Filter = new Class({
return this._placeholder; return this._placeholder;
} }
}, },
filter: filter: {
{
type: Sql.Filter type: Sql.Filter
,set: function(x) { ,set: function(x) {
this._filter = x; this._filter = x;
@ -330,7 +326,7 @@ Vn.Filter = new Class({
,get: function() { ,get: function() {
return this._filter; return this._filter;
} }
}, }
} }
,_valueColumnIndex: 0 ,_valueColumnIndex: 0
@ -432,19 +428,25 @@ Vn.Filter = new Class({
if (!this._label) if (!this._label)
return; return;
var row = -1; let row = -1;
const model = this._model;
if (model) {
if (this._model.ready) if (this._model.ready)
row = this._model.searchByIndex(this._valueColumnIndex, this._value); row = model.searchByIndex(this._valueColumnIndex, this._value);
if (row != -1) { if (row != -1) {
var label = this._model.getByIndex(row, this._showColumnIndex); var label = model.getByIndex(row, this._showColumnIndex);
this._label.nodeValue = label; this._label.nodeValue = label;
this._emptyLabel = false; this._emptyLabel = false;
} else { } else {
this._emptyLabel = true; this._emptyLabel = true;
this._label.nodeValue = _('Loading...'); this._label.nodeValue = _('Loading...');
} }
} else {
this._emptyLabel = true;
this._label.nodeValue = '';
}
} }
}); });

View File

@ -62,7 +62,10 @@ module.exports = new Class({
} }
,_onConnError: function(conn, error) { ,_onConnError: function(conn, error) {
if (error instanceof Vn.JsonException) if (error instanceof Vn.JsonException) {
if (error.message)
Htk.Toast.showError(error.message);
else
switch (error.exception) { switch (error.exception) {
case 'BadLogin': case 'BadLogin':
Htk.Toast.showError(_('Invalid login')); Htk.Toast.showError(_('Invalid login'));
@ -84,7 +87,8 @@ module.exports = new Class({
break; break;
default: default:
Htk.Toast.showError(error.message); Htk.Toast.showError(error.message);
} else if (error.statusCode) }
} else if (error.statusCode) {
switch (error.statusCode) { switch (error.statusCode) {
case 401: case 401:
Htk.Toast.showError(_('Invalid login')); Htk.Toast.showError(_('Invalid login'));
@ -93,7 +97,7 @@ module.exports = new Class({
default: default:
Htk.Toast.showError(error.message); Htk.Toast.showError(error.message);
} }
else { } else {
console.error(error); console.error(error);
this._notifyError(error); this._notifyError(error);
} }

View File

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

View File

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

View File

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

View File

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