77) Form COC extension method
/// <summary>
/// The <c>AvaEntAssetMaintenancePlanFrm_Extension</c> contains the TransMountain extending logic for the <c>EntAssetMaintenancePlan</c> form.
/// </summary>
[ExtensionOf(formStr(EntAssetMaintenancePlan))]
final class AvaEntAssetMaintenancePlanFrm_Extension
{
public boolean isAvaCustomForm = false;
public EntAssetMaintenancePlan callerMaintenancePlan;
/// <summary>
/// set allow edit for maintenance program fields
/// </summary>
public void avaSetAllowEditForMaintenanceProgram()
{
var maintenancePlanDS = this.dataSource(formDataSourceStr(EntAssetMaintenancePlan, MaintenancePlan)) as FormDataSource;
EntAssetMaintenancePlan maintenancePlan = maintenancePlanDS.cursor();
maintenancePlanDS.object(fieldNum(EntAssetMaintenancePlan, AvaMaintenanceWorkOrderType)).allowEdit(maintenancePlan.AvaIsMaintenanceProgram);
maintenancePlanDS.object(fieldNum(EntAssetMaintenancePlan, AvaMaintenanceWorkOrderType)).mandatory(maintenancePlan.AvaIsMaintenanceProgram);
maintenancePlanDS.object(fieldNum(EntAssetMaintenancePlan, AvaMaintenanceWorkOrderPool)).allowEdit(maintenancePlan.AvaIsMaintenanceProgram);
}
public void init()
{
isAvaCustomForm = this.args().parmEnumType() == EnumNum(AvaWorkOrderCheckListFormType)
&& this.args().parmEnum() == AvaWorkOrderCheckListFormType::AvaCustom;
if (isAvaCustomForm)
{
switch (this.args().dataset())
{
case tableNum(EntAssetMaintenancePlan):
callerMaintenancePlan = this.args().record();
break;
}
}
next init();
this.initVisibility();
this.avaUpdateFormCaption();
}
private void initVisibility()
{
FormTabPageControl FunctionalLocationTypes = this.design().controlName(formControlStr(EntAssetMaintenancePlan, TabPageFunctionalLocationTypes)) as FormTabPageControl;
FormTabPageControl FunctionalLocations = this.design().controlName(formControlStr(EntAssetMaintenancePlan, TabPageFunctionalLocations)) as FormTabPageControl;
FormTabPageControl ObjectTypes = this.design().controlName(formControlStr(EntAssetMaintenancePlan, TabPageObjectTypes)) as FormTabPageControl;
FormGroupControl Interval = this.design().controlName(formControlStr(EntAssetMaintenancePlan, Interval)) as FormGroupControl;
FormButtonControl AddHourLine = this.design().controlName(formControlStr(EntAssetMaintenancePlan, AddHourLine)) as FormButtonControl;
FormButtonControl AddCounterLine = this.design().controlName(formControlStr(EntAssetMaintenancePlan, AddCounterLine)) as FormButtonControl;
// Query range to filter on MaintenancePlantemplate form
QueryBuildDataSource qbdsMaintenancePlan = MaintenancePlan_DS.queryBuildDataSource();
QueryBuildRange qbRange = qbdsMaintenancePlan.addRange(fieldNum(EntAssetMaintenancePlan, AvaIsMaintenanceProgram));
qbRange.value(queryValue(isAvaCustomForm ? NoYes::Yes : NoYes::No));
AvaMaintenanceProgram.visible(isAvaCustomForm ? isAvaCustomForm : false);
AddButton.visible(isAvaCustomForm ? isAvaCustomForm : false );
FunctionalLocations.visible(isAvaCustomForm ? !isAvaCustomForm : true);
FunctionalLocationTypes.visible(isAvaCustomForm ? !isAvaCustomForm : true);
ObjectTypes.visible(isAvaCustomForm ? !isAvaCustomForm : true);
Interval.visible(isAvaCustomForm ? !isAvaCustomForm : true);
AddHourLine.visible(isAvaCustomForm ? !isAvaCustomForm : true);
AddCounterLine.visible(isAvaCustomForm ? !isAvaCustomForm : true);
// MaintenancePlanLine data source fields visible and non visible.
MaintenancePlanLine_DS.object(fieldNum(EntAssetMaintenancePlanLine, AutoCreate)).visible(isAvaCustomForm ? !isAvaCustomForm : true);
MaintenancePlanLine_DS.object(fieldNum(EntAssetMaintenancePlanLine, SuppressOverlappingJobs)).visible(isAvaCustomForm ? !isAvaCustomForm : true);
MaintenancePlanLine_DS.object(fieldNum(EntAssetMaintenancePlanLine, ActivityIntervalType)).visible(isAvaCustomForm ? !isAvaCustomForm : true);
MaintenancePlanLine_DS.object(fieldNum(EntAssetMaintenancePlanLine, ActivityInterval)).visible(isAvaCustomForm ? !isAvaCustomForm : true);
MaintenancePlanLine_DS.object(fieldNum(EntAssetMaintenancePlanLine, SuppressOverlappingJobs)).visible(isAvaCustomForm ? !isAvaCustomForm : true);
//MaintenancePlanLine_EntAssetMaintenancePlanLineTime_DS fileds enable and disable
MaintenancePlanLine_EntAssetMaintenancePlanLineTime_DS.object(fieldNum(EntAssetMaintenancePlanLineTime, MaintenanceDate)).visible(isAvaCustomForm ? !isAvaCustomForm : true);
MaintenancePlanLine_EntAssetMaintenancePlanLineTime_DS.object(fieldNum(EntAssetMaintenancePlanLineTime, ActivityIntervalPeriod)).visible(isAvaCustomForm ? !isAvaCustomForm : true);
//MaintenancePlanLine_EntAssetMaintenancePlanLineCounter_DS fields enable and disable
MaintenancePlanLine_EntAssetMaintenancePlanLineCounter_DS.object(fieldNum(EntAssetMaintenancePlanLineCounter, Days)).visible(isAvaCustomForm ? !isAvaCustomForm : true);
MaintenancePlanLine_EntAssetMaintenancePlanLineCounter_DS.object(fieldNum(EntAssetMaintenancePlanLineCounter, CounterType)).visible(isAvaCustomForm ? !isAvaCustomForm : true);
}
public boolean parmIsAvaCustomForm()
{
return isAvaCustomForm;
}
public void avaAddLine(str _tableName)
{
if(this.viewEditModeHelper().isInViewMode())
{
this.viewEditModeHelper().setViewEditMode(ViewEditMode::Edit);
}
MaintenancePlanLine_DS.research(false);
Map typesToCreate = new Map(Types::String, Types::String);
typesToCreate.insert(MaintenancePlanLine_DS.name(), _tableName);
MaintenancePlanLine_DS.createTypes(typesToCreate);
}
public void avaUpdateFormCaption()
{
FormStringControl avaMainPlanLabel = this.design().controlName(formControlStr(EntAssetMaintenancePlan, Identification_MaintenancePlanId)) as FormStringControl;
if(isAvaCustomForm)
{
this.design().caption("@AvaTransMountain:AvaMaintenanceProgramTemplate_Label");
avaMainPlanLabel.label("@AvaTransMountain:AvaMaintenanceProgramTemplate_Label");
}
}
}
Comments
Post a Comment