Déplacement interfaces dans script séparé (suite).
This commit is contained in:
parent
0ad046f095
commit
0b3392cbd8
@ -14,7 +14,7 @@ export class freeCSV2HTML
|
|||||||
public parseDatas: papaParseDatas[] = [];
|
public parseDatas: papaParseDatas[] = [];
|
||||||
public parseErrors: papaParseErrors[] = [];
|
public parseErrors: papaParseErrors[] = [];
|
||||||
public datasHTML: string = "";
|
public datasHTML: string = "";
|
||||||
public stopIfParseErrors : boolean = false;
|
public stopIfParseErrors: boolean = false;
|
||||||
|
|
||||||
set datasViewElt(elt: domElement)
|
set datasViewElt(elt: domElement)
|
||||||
{
|
{
|
||||||
@ -38,7 +38,7 @@ export class freeCSV2HTML
|
|||||||
|
|
||||||
set datasSelectors(selectionElts: selectors[])
|
set datasSelectors(selectionElts: selectors[])
|
||||||
{
|
{
|
||||||
this._datasSelectors=[]; // remise à zéro
|
this._datasSelectors=[];
|
||||||
let checkContainerExist: HTMLElement|null;
|
let checkContainerExist: HTMLElement|null;
|
||||||
for(let i = 0; i < selectionElts.length; i++)
|
for(let i = 0; i < selectionElts.length; i++)
|
||||||
{
|
{
|
||||||
@ -108,7 +108,7 @@ export class freeCSV2HTML
|
|||||||
|
|
||||||
await this.parse();
|
await this.parse();
|
||||||
|
|
||||||
if(this.parseDatas.length === 0 || this.parseMeta!.fields === undefined) // je force avec "!", car l'existence de parseMeta certaine après parse().
|
if(this.parseDatas.length === 0 || this.parseMeta!.fields === undefined) // je force avec "!", car l'existence de parseMeta est certaine après parse().
|
||||||
throw new Error(errors.datasNotFound);
|
throw new Error(errors.datasNotFound);
|
||||||
else if(this.stopIfParseErrors && this.parseErrors.length!==0)
|
else if(this.stopIfParseErrors && this.parseErrors.length!==0)
|
||||||
console.error(this.parseErrors);
|
console.error(this.parseErrors);
|
||||||
@ -140,15 +140,14 @@ export class freeCSV2HTML
|
|||||||
}
|
}
|
||||||
if(values.length > 0)
|
if(values.length > 0)
|
||||||
{
|
{
|
||||||
values.sort();
|
values.sort(); // à revoir, car gère mal la casse, les nombres, etc.
|
||||||
this._datasSelectors[i].name = colName;
|
this._datasSelectors[i].name=colName;
|
||||||
this._datasSelectors[i].values=values;
|
this._datasSelectors[i].values=values;
|
||||||
selectorsHTML[i]="<label for='CSVDatasSelector"+i+"'>"+colName+" : </label><select name='CSVDatasSelector"+i+"' id='CSVDatasSelector"+i+"'><option value='0'>----</option>";
|
selectorsHTML[i]="<label for='CSVDatasSelector"+i+"'>"+colName+" : </label><select name='CSVDatasSelector"+i+"' id='CSVDatasSelector"+i+"'><option value='0'>----</option>";
|
||||||
for(let j in values)
|
for(let j in values)
|
||||||
selectorsHTML[i]+="<option value='"+(Number(j)+1)+"'>"+values[j]+"</option>";
|
selectorsHTML[i]+="<option value='"+(Number(j)+1)+"'>"+values[j]+"</option>";
|
||||||
selectorsHTML[i]+="</select>";
|
selectorsHTML[i]+="</select>";
|
||||||
this._datasSelectors[i].eltDOM!.innerHTML=selectorsHTML[i];
|
this._datasSelectors[i].eltDOM!.innerHTML=selectorsHTML[i];
|
||||||
// On recharge l'affichage des données lors de chaque choix de l'utilisateur :
|
|
||||||
let selectElement = document.getElementById("CSVDatasSelector"+i) as HTMLInputElement;
|
let selectElement = document.getElementById("CSVDatasSelector"+i) as HTMLInputElement;
|
||||||
selectElement.addEventListener('change', function(e)
|
selectElement.addEventListener('change', function(e)
|
||||||
{
|
{
|
||||||
@ -206,5 +205,4 @@ export class freeCSV2HTML
|
|||||||
datasHTML+="</tbody></table>";
|
datasHTML+="</tbody></table>";
|
||||||
return datasHTML;
|
return datasHTML;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
11
src/freeCSV2HTMLInterfaces.ts
Normal file
11
src/freeCSV2HTMLInterfaces.ts
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
export interface domElement
|
||||||
|
{
|
||||||
|
id: string;
|
||||||
|
eltDOM?: HTMLElement;
|
||||||
|
}
|
||||||
|
export interface selectors extends domElement
|
||||||
|
{
|
||||||
|
colCSV: number;
|
||||||
|
name?: string;
|
||||||
|
values? : string[];
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user