-
Notifications
You must be signed in to change notification settings - Fork 802
Additional Feature Implementing isCloneMode
Victor Tomaili edited this page May 3, 2021
·
1 revision
For everyone that wants this feature, i like to share my implementation of it.
First Create a Interface:
public interface IClonedRow
{
Boolean? IsCloned { get; set; }
}
Change the XXXRow.cs signature
...
public sealed class XXXRow : Row, IIdRow, INameRow, IClonedRow
...
Add Property to the XXXRow.cs
...
[NotMapped, NotFilterable, Hidden]
public bool? IsCloned
{
get { return Fields.IsCloned[this]; }
set { Fields.IsCloned[this] = value; }
}
...
Change the RowFields class accordingly
...
public class RowFields : RowFieldsBase
{
public BooleanField IsCloned;
...
}
...
On your Form.cs
public class YOUR_FORM {
// ...
public Boolean IsCloned { get; set; }
}
Override the method isCloneMode in XXXDialog.ts
...
protected isCloneMode(): boolean {
return this.entity.IsCloned;
}
...
Override the getCloningEntity in XXXDialog.ts
...
protected getCloningEntity() {
var clone = super.getCloningEntity();
//indicate that this is a clone
clone.IsCloned = true;
return clone;
}
...
Override the afterLoadEntity in XXXDialog.ts
...
protected afterLoadEntity() {
super.afterLoadEntity();
if (this.isCloneMode())
{
Q.notifyInfo("I'm a clone :) !!!");
}
else if (this.isNew())
{
Q.notifyInfo("I'm a newborn :) !!!");
}
else
{
Q.notifyInfo("I exist already you can edit me :) !!!");
}
}
...
Copyright © Serenity Platform 2017-present. All rights reserved.
Documentation | Serene Template | Live Demo | Premium Support | Issues | Discussions