Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

구역간 전환 시 해당 구역의 데이터가 폼에 반영되지 않는 문제 수정 #75

Merged
merged 1 commit into from
Aug 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@
let disabled: number[] = original?.disabled ?? [];
let subsections: LockerSubsection[] = original?.subsections ?? [];

$: if ((floor && originalId) || isNew) {
initializeValues();
}

const isNotUppercaseAlphabet = new RegExp('[^A-Z]+');
const isNotNumeric = new RegExp('[^0-9]+');

Expand All @@ -41,6 +45,16 @@

$: isSaveDisabled = !isModified || !isAppliable ? true : undefined;

function initializeValues() {
floorInput = floor ?? '';
id = originalId ?? '';
height = original?.height ?? 0;
disabledInput = null;
disabledInputInvalid = undefined;
disabled = original?.disabled ?? [];
subsections = original?.subsections ?? [];
}

function isExistingLockerNum(num: number) {
return !!subsections.find(({ range }) => range[0] <= num && range[1] >= num);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@
let department = subsection?.department;
let invalidText: string;

$: if (subsection) {
initializeValues();
}

$: if (rangeStart && rangeEnd && department) {
if (rangeStart <= 0) {
invalidText = '값 무시됨: 구역 시작은 1보다 커야함';
Expand All @@ -40,6 +44,13 @@
invalidText = '값 무시됨: 모든 값이 입력되지 않음';
}

function initializeValues() {
rangeStart = subsection?.range?.[0] ?? 0;
rangeEnd = subsection?.range?.[1] ?? 0;
department = subsection?.department;
invalidText = undefined;
}

function removeSubsection() {
dispatch('remove', {});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@

let newSubsections: LockerSubsection[] = [...subsections];

$: if (subsections) {
newSubsections = [...subsections];
}

function addSubsection() {
newSubsections = [...newSubsections, { range: [0, 0], department: '' }];
}
Expand Down