Skip to content

Commit f64f6db

Browse files
authored
Merge pull request #701 from Lemoncode/fix-old-version-placeholder-input
fix old version placeholder
2 parents 50fc5be + 65517bb commit f64f6db

File tree

1 file changed

+44
-2
lines changed

1 file changed

+44
-2
lines changed

src/core/local-disk/shapes-to-document.mapper.ts

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {
44
createDefaultCanvasSize,
55
DocumentModel,
66
} from '../providers/canvas/canvas.model';
7-
import { QuickMockFileContract } from './local-disk.model';
7+
import { Page, QuickMockFileContract } from './local-disk.model';
88
import { APP_CONSTANTS } from '../providers/canvas/canvas.model';
99

1010
export const mapFromShapesArrayToQuickMockFileDocument = (
@@ -24,14 +24,56 @@ export const mapFromQuickMockFileDocumentToApplicationDocument = (
2424
): DocumentModel => {
2525
return {
2626
activePageIndex: 0,
27-
pages: fileDocument.pages,
27+
pages: AdaptMinor_0_2_Updates(fileDocument.pages),
2828
customColors:
2929
fileDocument.customColors ||
3030
new Array(APP_CONSTANTS.COLOR_SLOTS).fill(null),
3131
size: fileDocument.size ?? createDefaultCanvasSize(),
3232
};
3333
};
3434

35+
const AdaptMinor_0_2_Updates = (pages: Page[]): Page[] => {
36+
return pages.map(page => {
37+
return {
38+
...page,
39+
shapes: page.shapes.map(
40+
AddDefaultValuesForInputPropsPlaceHolderAndPassword
41+
),
42+
};
43+
});
44+
};
45+
46+
const AddDefaultValuesForInputPropsPlaceHolderAndPassword = (
47+
shape: ShapeModel
48+
) => {
49+
switch (shape.type) {
50+
case 'input':
51+
return {
52+
...shape,
53+
otherProps: {
54+
...shape.otherProps,
55+
isPlaceholder:
56+
// Small update no need to go for 0_3, but input placeHolder needs to have default value
57+
// if undefined
58+
shape.otherProps?.isPlaceholder !== undefined
59+
? shape.otherProps?.isPlaceholder
60+
: true,
61+
textColor:
62+
// Small update, no need to go for 0_3,
63+
// but input textColor needs to have default value
64+
// if undefined, and textColor was placeholder gray color
65+
// in this case change it to black
66+
shape.otherProps?.isPlaceholder === undefined &&
67+
shape.otherProps?.textColor === '#8c8c8c'
68+
? '#000000'
69+
: shape.otherProps?.textColor,
70+
},
71+
};
72+
default:
73+
return shape;
74+
}
75+
};
76+
3577
const mapTextElementFromV0_1ToV0_2 = (shape: ShapeModel): ShapeModel => {
3678
switch (shape.type) {
3779
case 'heading1':

0 commit comments

Comments
 (0)