수정 및 삭제
1. 직원 정보를 수정 할 수 있어야 한다.
2. 표시 순서를 위한 OrderNo를 변경 할 수 있어야 한다.
3. 저장 버튼은 필수 입력값이 들어가야 활성화 된다.
편집 버튼
Visible 속성
편집 버튼은 편집 모두 이면서 회사를 선택하지 않고 직원을 선택 했을 때만 표시
And(!editMode, !newMode, !deleteMode, CurrentItem.Level > 0)
|
OnSelect 속성
편집 버튼을 누루면 최신 데이터를 가져와서 ColOrgAllList 컬렉션을 생성
소속 부서의 순서를 변경하기 위해 ColEmployeeSub1, ColEmployeeSub2, ColEmployeeSub3 3개의 컬렉션을 생성
UpdateContext({ editMode: true, selectedRecord: EmployeeGallery.Selected });
// ColOrgAllList 컬렉션 생성 - 회사일 경우 Type을 Company로 설정
Clear(ColOrgAllList);
ForAll(
OrgCompany,
Collect(ColOrgAllList,
{
Name: Name,
Level: 0,
OrderNo: Text(OrderNo,"00") & "000000000000000000000000000000",
Visible:true,
Type:"Company"
}
)
);
// ColOrgAllList 컬렉션 추가 - 부서 값 추가 Type을 Department로 설정
ForAll(
Filter(ColDepartment,Level<>0),
Collect(ColOrgAllList,
{
Company:Company,
Name: Name,
DepartmentID: ID,
Level: Level,
OrderNo: OrderNo,
Visible:true,
Type:"Department"
}
)
);
// ColOrgAllList 컬렉션 추가 - 직원 추가 Type을 Employee로 설정, Department 값은 필수 값
ForAll(
Filter(ColEmployee,!IsBlank(No) And Level<>0),
Collect(ColOrgAllList,
{
Company:Company,
CompanyID:CompanyID,
Name: Name,
DepartmentID: DepartmentID,
Department:Department,
EmployeeID:ID,
Level: Level,
No:No,
OrderNo: OrderNo,
Jobtitle : Jobtitle,
Mail:Mail,
Phone:Phone,
Mobile:Mobile,
ShortNumber:ShortNumber,
Visible:true,
ResignationDate:ResignationDate,
JoinDate:JoinDate,
Specialize:Specialize,
Type:"Employee",
DepartmentNum : 1
}
)
);
// ColOrgAllList 컬렉션 추가 - 직원 추가 Type을 Employee로 설정, Department1 (겸직부서1) 값이 있는 경우 추가
ForAll(
Filter(ColEmployee,!IsBlank(No1)),
Collect(ColOrgAllList,
{
Company:Company,
CompanyID:CompanyID,
Name: Name,
DepartmentID: DepartmentID1,
Department:Department1,
EmployeeID:ID,
Level: Level1,
No:No1,
OrderNo: OrderNo1,
Jobtitle : Jobtitle,
Mail:Mail,
Phone:Phone,
Mobile:Mobile,
ShortNumber:ShortNumber,
Visible:true,
ResignationDate:ResignationDate,
JoinDate:JoinDate,
Specialize:Specialize,
Type:"Employee",
DepartmentNum : 2
}
)
);
// ColOrgAllList 컬렉션 추가 - 직원 추가 Type을 Employee로 설정, Department2 (겸직부서2) 값이 있는 경우 추가
ForAll(
Filter(ColEmployee,!IsBlank(No2)),
Collect(ColOrgAllList,
{
Company:Company,
CompanyID:CompanyID,
Name: Name,
DepartmentID: DepartmentID2,
Department:Department2,
EmployeeID:ID,
Level: Level2,
No:No2,
OrderNo: OrderNo2,
Jobtitle : Jobtitle,
Mail:Mail,
Phone:Phone,
Mobile:Mobile,
ShortNumber:ShortNumber,
Visible:true,
ResignationDate:ResignationDate,
JoinDate:JoinDate,
Specialize:Specialize,
Type:"Employee",
DepartmentNum : 3
}
)
);
// OrderNo 정렬을 위한 컬렉션 생성
Clear(ColEmployeeSub1);
ForAll(
Filter(Sort(ColOrgAllList,OrderNo),Type="Employee" And IsBlank(ResignationDate) And StartsWith(OrderNo,Left(CurrentItem.OrderNo,CurrentItem.Level * 5 + 2))
),
Collect(
ColEmployeeSub1,
{
cID: First(Sort(ColEmployeeSub1,cID,SortOrder.Descending)).cID +1,
EmployeeID:EmployeeID,
DepartmentID:EmployeeDepartmentID,
DepartmentNum:DepartmentNum,
Name:Name,
No:No,
OrderNo:OrderNo,
cIsCheck:false
})
);
// OrderNo1 정렬을 위한 컬렉션 생성
If(!IsBlank(LookUp(OrgEmployee,ID=CurrentItem.ID).OrderNo1),
Clear(ColEmployeeSub2);
ForAll(
Filter(Sort(ColOrgAllList,OrderNo),Type="Employee" And IsBlank(ResignationDate) And StartsWith(OrderNo,Left(LookUp(OrgEmployee,ID=CurrentItem.ID).OrderNo1,LookUp(OrgEmployee,ID=CurrentItem.ID).Level1 * 5 + 2))
),
Collect(
ColEmployeeSub2,
{
cID: First(Sort(ColEmployeeSub2,cID,SortOrder.Descending)).cID +1,
EmployeeID:EmployeeID,
DepartmentID:EmployeeDepartmentID,
DepartmentNum:DepartmentNum,
Name:Name,
No:No,
OrderNo:OrderNo,
cIsCheck:false
})
),
Clear(ColEmployeeSub2);
);
// OrderNo2 정렬을 위한 컬렉션 생성
If(!IsBlank(LookUp(OrgEmployee,ID=CurrentItem.ID).OrderNo2),
Clear(ColEmployeeSub3);
ForAll(
Filter(Sort(ColOrgAllList,OrderNo),Type="Employee" And IsBlank(ResignationDate) And StartsWith(OrderNo,Left(LookUp(OrgEmployee,ID=CurrentItem.ID).OrderNo2,LookUp(OrgEmployee,ID=CurrentItem.ID).Level2 * 5 + 2))
),
Collect(
ColEmployeeSub3,
{
cID: First(Sort(ColEmployeeSub3,cID,SortOrder.Descending)).cID +1,
EmployeeID:EmployeeID,
DepartmentID:EmployeeDepartmentID,
DepartmentNum:DepartmentNum,
Name:Name,
No:No,
OrderNo:OrderNo,
cIsCheck:false
})
),
Clear(ColEmployeeSub3);
)
|
저장 버튼
DisplayMode 속성 - 새로 만들기와 동일한 조건
필수 값이 입력 되었을 경우만 저장 버튼 활성화
// 이름, 메일주소, 소속부서 값이 비어 있으면 저장 버튼을 비활성화
If(!IsBlank(EmployeeName.Text) And !IsBlank(EmployeeMail.Text) And !IsBlank(EmployeeIDComboBox.Selected.Name),DisplayMode.Edit,DisplayMode.Disabled)
|
OnSelect 속성
저장은 컬렉션 값과 SharePoint Lists 값 둘다 저장이 가능하게 설정
If(newMode,
SubmitForm(Form1_5);
// ColDepartment 초기화 및 생성
ClearCollect(ColDepartment,AddColumns(OrgDepartment,NewID,ID));
// OrgCompany의 회사 정보를 ColDepartment에 추가
ForAll(
OrgCompany,
Collect(
ColDepartment,
{
No: Text(OrderNo,"00"),
CompanyID : ID,
Name: Name,
Level: 0,
OrderNo: Text(OrderNo,"00") & "000000000000000000000000000000",
Visible:true
}
)
);
// ColEmployee 초기화 및 생성
ClearCollect(ColEmployee,AddColumns(OrgEmployee,NewID,ID));
ForAll(
OrgCompany,
Collect(
ColEmployee,
{
No: Text(OrderNo,"00"),
CompanyID : ID,
Name: Name,
Level: 0,
OrderNo: Text(OrderNo,"00") & "000000000000000000000000000000",
Visible:true
}
)
),
//ColEmployee에 변경된 값을 저장
UpdateIf(ColEmployee,ID=CurrentItem.ID,
{
Name:EmployeeName.Text,
Jobtitle:JobtitleDropdown2_1_2.Selected.Name,
Position:PositionDropdown3_1_2.Selected.Name,
Mail: EmployeeMailResult.Text,
Mobile:EmployeeMobile.Text,
Phone:EmployeePhone.Text,
ShortNumber:Value(EmployeeShortNumber.Text),
Specialize:EmployeeSpecialize.Text,
JoinDate:EmployeeJoinDate.SelectedDate,
CompanyID:CompanyIDDropdown.Selected.ID,
Company:CompanyIDDropdown.Selected.Name,
DepartmentID:EmployeeIDComboBox.Selected.ID,
DepartmentID1:EmployeeID1ComboBox.Selected.ID,
DepartmentID2:EmployeeID2ComboBox.Selected.ID,
Department:EmployeeIDComboBox.Selected.Name,
Department1:EmployeeID1ComboBox.Selected.Name,
Department2:EmployeeID2ComboBox.Selected.Name,
Level:Value(EmployeeLevel.Text),
Level1:Value(EmployeeLevel1.Text),
Level2:Value(EmployeeLevel2.Text),
No:EmployeeNo.Text,
No1:EmployeeNo1.Text,
No2:EmployeeNo2.Text,
OrderNo:EmployeeOrderNo.Text,
OrderNo1:EmployeeOrderNo1.Text,
OrderNo2:EmployeeOrderNo2.Text,
ResignationDate:EmployeeResignationDate.SelectedDate
});
SubmitForm(Form1_5); //OrgEmployee에 값을 저장
//OrderNo 변경 순서를 OrgEmployee에 순서가 변경된 값에 대한 No와 OrderNo를 변경
//여기서 DepartmentNum을 이용해서 No, No1, No2 혹은 OrderNo, OrderNo1, OrderNo2 인지 확인 후 변경
If(!IsBlank(LookUp(ColEmployeeSub1,cIsCheck= true )),
ForAll(RenameColumns(Filter(ColEmployeeSub1,cIsCheck=true),EmployeeID,EID),
If(
DepartmentNum=1,Patch(OrgEmployee,LookUp(OrgEmployee,ID=EID),{No:No,OrderNo:OrderNo}),
DepartmentNum=2,Patch(OrgEmployee,LookUp(OrgEmployee,ID=EID),{No1:No,OrderNo1:OrderNo}),
DepartmentNum=3,Patch(OrgEmployee,LookUp(OrgEmployee,ID=EID),{No2:No,OrderNo2:OrderNo}))
)
);
If(!IsBlank(LookUp(ColEmployeeSub2,cIsCheck= true )),
ForAll(RenameColumns(Filter(ColEmployeeSub2,cIsCheck=true),EmployeeID,EID),
If(
DepartmentNum=1,Patch(OrgEmployee,LookUp(OrgEmployee,ID=EID),{No:No,OrderNo:OrderNo}),
DepartmentNum=2,Patch(OrgEmployee,LookUp(OrgEmployee,ID=EID),{No1:No,OrderNo1:OrderNo}),
DepartmentNum=3,Patch(OrgEmployee,LookUp(OrgEmployee,ID=EID),{No2:No,OrderNo2:OrderNo}))
)
);
If(!IsBlank(LookUp(ColEmployeeSub3,cIsCheck= true )),
ForAll(RenameColumns(Filter(ColEmployeeSub3,cIsCheck=true),EmployeeID,EID),
If(
DepartmentNum=1,Patch(OrgEmployee,LookUp(OrgEmployee,ID=EID),{No:No,OrderNo:OrderNo}),
DepartmentNum=2,Patch(OrgEmployee,LookUp(OrgEmployee,ID=EID),{No1:No,OrderNo1:OrderNo}),
DepartmentNum=3,Patch(OrgEmployee,LookUp(OrgEmployee,ID=EID),{No2:No,OrderNo2:OrderNo}))
)
);
//OrderNo 변경 순서를 ColEmployee에 순서가 변경된 값에 대한 No와 OrderNo를 변경
//여기서 DepartmentNum을 이용해서 No, No1, No2 혹은 OrderNo, OrderNo1, OrderNo2 인지 확인 후 변경
If(!IsBlank(LookUp(ColEmployeeSub1,cIsCheck= true )),
ForAll(RenameColumns(Filter(ColEmployeeSub1,cIsCheck=true),EmployeeID,EID),
If(
DepartmentNum=1,Patch(ColEmployee,LookUp(ColEmployee,ID=EID),{No:No,OrderNo:OrderNo}),
DepartmentNum=2,Patch(ColEmployee,LookUp(ColEmployee,ID=EID),{No1:No,OrderNo1:OrderNo}),
DepartmentNum=3,Patch(ColEmployee,LookUp(ColEmployee,ID=EID),{No2:No,OrderNo2:OrderNo}))
)
);
If(!IsBlank(LookUp(ColEmployeeSub2,cIsCheck= true )),
ForAll(RenameColumns(Filter(ColEmployeeSub2,cIsCheck=true),EmployeeID,EID),
If(
DepartmentNum=1,Patch(ColEmployee,LookUp(ColEmployee,ID=EID),{No:No,OrderNo:OrderNo}),
DepartmentNum=2,Patch(ColEmployee,LookUp(ColEmployee,ID=EID),{No1:No,OrderNo1:OrderNo}),
DepartmentNum=3,Patch(ColEmployee,LookUp(ColEmployee,ID=EID),{No2:No,OrderNo2:OrderNo}))
)
);
If(!IsBlank(LookUp(ColEmployeeSub3,cIsCheck= true )),
ForAll(RenameColumns(Filter(ColEmployeeSub3,cIsCheck=true),EmployeeID,EID),
If(
DepartmentNum=1,Patch(ColEmployee,LookUp(ColEmployee,ID=EID),{No:No,OrderNo:OrderNo}),
DepartmentNum=2,Patch(ColEmployee,LookUp(ColEmployee,ID=EID),{No1:No,OrderNo1:OrderNo}),
DepartmentNum=3,Patch(ColEmployee,LookUp(ColEmployee,ID=EID),{No2:No,OrderNo2:OrderNo}))
)
);
//ColOrgAllList 값을 업데이트
Clear(ColOrgAllList);
ForAll(
OrgCompany,
Collect(ColOrgAllList,
{
Name: Name,
Level: 0,
OrderNo: Text(OrderNo,"00") & "000000000000000000000000000000",
Visible:true,
Type:"Company"
}
)
);
ForAll(
Filter(ColDepartment,Level<>0),
Collect(ColOrgAllList,
{
Company:Company,
Name: Name,
DepartmentID: ID,
Level: Level,
OrderNo: OrderNo,
Visible:true,
Type:"Department"
}
)
);
ForAll(
Filter(ColEmployee,!IsBlank(No) And Level<>0),
Collect(ColOrgAllList,
{
Company:Company,
CompanyID:CompanyID,
EmpNo : EmpNo,
Name: Name,
DepartmentID: DepartmentID,
Department:Department,
EmployeeID:ID,
Level: Level,
No:No,
OrderNo: OrderNo,
Jobtitle : Jobtitle,
Mail:Mail,
Phone:Phone,
Mobile:Mobile,
ShortNumber:ShortNumber,
Visible:true,
ResignationDate:ResignationDate,
Specialize:Specialize,
Type:"Employee",
DepartmentNum : 1
}
)
);
ForAll(
Filter(ColEmployee,!IsBlank(No1)),
Collect(ColOrgAllList,
{
Company:Company,
CompanyID:CompanyID,
EmpNo : EmpNo,
Name: Name,
DepartmentID: DepartmentID1,
Department:Department1,
EmployeeID:ID,
Level: Level1,
No:No1,
OrderNo: OrderNo1,
Jobtitle : Jobtitle,
Mail:Mail,
Phone:Phone,
Mobile:Mobile,
ShortNumber:ShortNumber,
Visible:true,
ResignationDate:ResignationDate,
Specialize:Specialize,
Type:"Employee",
DepartmentNum : 2
}
)
);
ForAll(
Filter(ColEmployee,!IsBlank(No2)),
Collect(ColOrgAllList,
{
Company:Company,
CompanyID:CompanyID,
EmpNo : EmpNo,
Name: Name,
DepartmentID: DepartmentID2,
Department:Department2,
EmployeeID:ID,
Level: Level2,
No:No2,
OrderNo: OrderNo2,
Jobtitle : Jobtitle,
Mail:Mail,
Phone:Phone,
Mobile:Mobile,
ShortNumber:ShortNumber,
Visible:true,
ResignationDate:ResignationDate,
Specialize:Specialize,
Type:"Employee",
DepartmentNum : 2
}
)
);
// OrderNo를 변경할 수 있는 Collection을 업데이트
Clear(ColEmployeeSub1);
ForAll(
Filter(Sort(ColOrgAllList,OrderNo),Type="Employee" And StartsWith(OrderNo,Left(CurrentItem.OrderNo,CurrentItem.Level * 5 + 2))
),
Collect(
ColEmployeeSub1,
{
cID: First(Sort(ColEmployeeSub1,cID,SortOrder.Descending)).cID +1,
EmployeeID:EmployeeID,
DepartmentID:EmployeeDepartmentID,
DepartmentNum:DepartmentNum,
Name:Name,
No:No,
OrderNo:OrderNo,
cIsCheck:false
})
);
If(!IsBlank(LookUp(OrgEmployee,ID=CurrentItem.ID).OrderNo1),
Clear(ColEmployeeSub2);
ForAll(
Filter(Sort(ColOrgAllList,OrderNo),Type="Employee" And StartsWith(OrderNo,Left(LookUp(OrgEmployee,ID=CurrentItem.ID).OrderNo1,LookUp(OrgEmployee,ID=CurrentItem.ID).Level1 * 5 + 2))
),
Collect(
ColEmployeeSub2,
{
cID: First(Sort(ColEmployeeSub2,cID,SortOrder.Descending)).cID +1,
EmployeeID:EmployeeID,
DepartmentID:EmployeeDepartmentID,
DepartmentNum:DepartmentNum,
Name:Name,
No:No,
OrderNo:OrderNo,
cIsCheck:false
})
),
Clear(ColEmployeeSub2);
);
If(!IsBlank(LookUp(OrgEmployee,ID=CurrentItem.ID).OrderNo2),
Clear(ColEmployeeSub3);
ForAll(
Filter(Sort(ColOrgAllList,OrderNo),Type="Employee" And StartsWith(OrderNo,Left(LookUp(OrgEmployee,ID=CurrentItem.ID).OrderNo2,LookUp(OrgEmployee,ID=CurrentItem.ID).Level2 * 5 + 2))
),
Collect(
ColEmployeeSub3,
{
cID: First(Sort(ColEmployeeSub3,cID,SortOrder.Descending)).cID +1,
EmployeeID:EmployeeID,
DepartmentID:EmployeeDepartmentID,
DepartmentNum:DepartmentNum,
Name:Name,
No:No,
OrderNo:OrderNo,
cIsCheck:false
})
),
Clear(ColEmployeeSub3);
);
);
|
OrderNo 변경은 기존 순서 변경에 대한 내용 참고
삭제 버튼
Visible 속성
삭제 버튼은 편집 모두 이면서 회사를 선택하지 않고 직원을 선택 했을 때만 표시
And(!editMode, !newMode, !deleteMode,CurrentItem.Level > 0)
|
OnSelect 속성
삭제 버튼 기본 값으로 별도 변경하지 않음.
UpdateContext({ deleteMode: true, deleteCancelled: false, selectedRecord: EmployeeGallery.Selected })
|
삭제
OnSelect
컬렉션과 SharePoint 목록 둘다 제거
Remove(ColEmployee,Filter(ColEmployee,ID=CurrentItem.ID));
Remove([@OrgEmployee], selectedRecord);
If(IsEmpty(Errors([@OrgEmployee], selectedRecord)), UpdateContext( { CurrentItem: First([@OrgEmployee]), itemSelected: false, editMode: false, newMode: false, deleteMode: false }));
|
댓글