gridview: allow to update row data

This commit is contained in:
DanyLE 2023-02-17 12:25:53 +01:00 committed by Dany LE
parent 0d8daa36e8
commit 1d1218acbd
3 changed files with 66 additions and 35 deletions

17
d.ts/antos.d.ts vendored
View File

@ -1482,6 +1482,23 @@ interface String {
*/
trimBy(arg: string): string;
}
/**
* Extend the Array prototype with some API
* functions used by AntOS API
*
* @interface Array
* @template T
*/
interface Array<T> {
/**
* Check if the array includes an element
*
* @param {T} element to check
* @returns {boolean}
* @memberof Array
*/
includes(element: T): boolean;
}
/**
* Extend the Data prototype with the
* [[timestamp]] function

View File

@ -157,6 +157,25 @@ interface String {
trimBy(arg: string): string;
}
/**
* Extend the Array prototype with some API
* functions used by AntOS API
*
* @interface Array
* @template T
*/
interface Array<T> {
/**
* Check if the array includes an element
*
* @param {T} element to check
* @returns {boolean}
* @memberof Array
*/
includes(element: T): boolean;
}
/**
* Extend the Data prototype with the
* [[timestamp]] function
@ -505,10 +524,8 @@ namespace OS {
*
* @memberof Version
*/
set version_string(v: string)
{
if(!v)
{
set version_string(v: string) {
if (!v) {
this.string = undefined;
this.major = undefined;
this.minor = undefined;
@ -526,8 +543,7 @@ namespace OS {
this.branch = 3;
if (arr.length >= 2 && br[arr[1]]) {
this.branch = br[arr[1]];
if(arr[2])
{
if (arr[2]) {
this.build_id = arr[2];
}
}
@ -551,8 +567,7 @@ namespace OS {
this.patch = Number(mt[2]);
}
}
get version_string(): string
{
get version_string(): string {
return this.string;
}
@ -807,9 +822,9 @@ namespace OS {
*/
export const REPOSITORY: string = "https://github.com/lxsang/antos";
/**
* Indicate whether the current de
*/
/**
* Indicate whether the current de
*/
export var mobile: boolean = false;
/**
* Register a model prototype to the system namespace.
@ -1268,8 +1283,8 @@ namespace OS {
//insert a temporal file selector
const o =
$("<input>")
.attr("type","file")
.attr("multiple","true");
.attr("type", "file")
.attr("multiple", "true");
o.on("change", function () {
const files = (o[0] as HTMLInputElement).files;
const n_files = files.length;
@ -1287,15 +1302,15 @@ namespace OS {
contentType: false,
processData: false,
})
.done(function (data) {
API.loaded(q, p, "OK");
resolve(data);
})
.fail(function (j, s, e) {
API.loaded(q, p, "FAIL");
o.remove();
reject(API.throwe(s));
});
.done(function (data) {
API.loaded(q, p, "OK");
resolve(data);
})
.fail(function (j, s, e) {
API.loaded(q, p, "FAIL");
o.remove();
reject(API.throwe(s));
});
});
return o.trigger("click");
});
@ -1332,7 +1347,7 @@ namespace OS {
* @param {string} p message string
*/
export function loading(q: number, p: string): void {
const data:API.AnnouncementDataType<number> = {} as API.AnnouncementDataType<number>;
const data: API.AnnouncementDataType<number> = {} as API.AnnouncementDataType<number>;
data.id = q;
data.message = p;
data.name = p;
@ -1352,7 +1367,7 @@ namespace OS {
* @param {string} m message status (`OK` of `FAIL`)
*/
export function loaded(q: number, p: string, m: string): void {
const data:API.AnnouncementDataType<boolean> = {} as API.AnnouncementDataType<boolean>;
const data: API.AnnouncementDataType<boolean> = {} as API.AnnouncementDataType<boolean>;
data.id = q;
data.message = p;
data.name = "OS";
@ -1445,7 +1460,7 @@ namespace OS {
* @returns {Promise<void>} a promise on the result data
*/
export function requires(l: string, force: boolean = false): Promise<void> {
return new Promise(async (resolve, reject) =>{
return new Promise(async (resolve, reject) => {
try {
if (!API.shared[l] || force) {
const libfp = l.asFileHandle();

View File

@ -101,6 +101,10 @@ namespace OS {
{
this.attach(v);
}
for (let celi = 0; celi < this.children.length; celi++) {
const cel = (this.children[celi] as GridCellPrototype);
cel.data = v[celi];
}
}
get data(): GenericObject<any>[] {
return this._data;
@ -785,10 +789,6 @@ namespace OS {
for (let i = 0; i < nmin; i++) {
const rowel = (this.refs.grid.children[i] as GridRowTag);
rowel.data = rows[i];
for (let celi = 0; celi < rowel.children.length; celi++) {
const cel = (rowel.children[celi] as GridCellPrototype);
cel.data = rows[i][celi];
}
}
// remove existing remaining rows
if (ndrows < ncrows) {
@ -930,20 +930,19 @@ namespace OS {
const el = rowel[0] as GridRowTag;
rowel[0].uify(this.observable);
el.data = row;
for (let cell of row) {
let tag = this.cellitem;
if (cell.tag) {
({ tag } = cell);
tag = cell.tag;
}
const el = $(`<${tag}>`).appendTo(rowel);
const element = el[0] as GridCellPrototype;
element.uify(this.observable);
element.oncellselect = (e) => this.cellselect(e, false);
element.oncelldbclick = (e) => this.cellselect(e, true);
element.data = cell;
}
el.data = row;
el.onrowselect = (e) => this.rowselect({
id: el.aid,
data: { item: el }