Etemplate: Check dirty before closing, ask if there are changes

This commit is contained in:
nathangray
2020-06-19 13:27:41 -06:00
parent 73515cd412
commit 52714f0a63
14 changed files with 149 additions and 23 deletions

View File

@@ -96,6 +96,18 @@ export class et2_inputWidget extends et2_valueWidget implements et2_IInput, et2_
this._labelContainer = null;
}
/**
* Make sure dirty flag is properly set
*/
doLoadingFinished() : boolean | JQueryPromise<unknown>
{
let result = super.doLoadingFinished();
this.resetDirty();
return result;
}
/**
* Load the validation errors from the server
*
@@ -300,7 +312,27 @@ export class et2_inputWidget extends et2_valueWidget implements et2_IInput, et2_
isDirty()
{
return this._oldValue != this.getValue();
let value = this.getValue();
if(typeof value !== typeof this._oldValue)
{
return true;
}
if(this._oldValue === value)
{
return false;
}
switch(typeof this._oldValue)
{
case "object":
if(this._oldValue.length !== value.length) return true;
for(let key in this._oldValue)
{
if(this._oldValue[key] !== value[key]) return true;
}
return false;
default:
return this._oldValue != value;
}
}
resetDirty()