Skip to content

Commit a7d822a

Browse files
OlgaLarinaOlgaLarina
and
OlgaLarina
authored
Change default value for logoPositionY (#6633)
* Change default value for logoPositionY fix after surveyjs/survey-library#9460 * Change default value for logoPositionY fix after surveyjs/survey-library#9460 * Change default value for logoPositionY fix after surveyjs/survey-library#9460 * Change default value for logoPositionY fix after surveyjs/survey-library#9460 --------- Co-authored-by: OlgaLarina <olga.larina.dev@gmail.com>
1 parent 7371361 commit a7d822a

File tree

3 files changed

+24
-18
lines changed

3 files changed

+24
-18
lines changed

packages/survey-creator-core/src/components/tabs/header-model.ts

+23-17
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ function getDefaultDescriptionSetting(isAdvanced?: boolean) {
119119
return result;
120120
}
121121

122-
function getHorizontalAlignment(questionName: string, defaultValue: string): IJsonPropertyInfo {
122+
function getHorizontalAlignment(questionName: string): IJsonPropertyInfo {
123123
return <IJsonPropertyInfo>{
124124
type: "buttongroup",
125125
name: questionName,
@@ -129,10 +129,10 @@ function getHorizontalAlignment(questionName: string, defaultValue: string): IJs
129129
{ value: "center" },
130130
{ value: "right", },
131131
],
132-
default: defaultValue,
132+
defaultFunc: () => Serializer.getProperty("cover", questionName).defaultValue,
133133
};
134134
}
135-
function getVerticalAlignment(questionName: string, defaultValue: string): IJsonPropertyInfo {
135+
function getVerticalAlignment(questionName: string): IJsonPropertyInfo {
136136
return <IJsonPropertyInfo>{
137137
type: "buttongroup",
138138
name: questionName,
@@ -143,7 +143,7 @@ function getVerticalAlignment(questionName: string, defaultValue: string): IJson
143143
{ value: "middle" },
144144
{ value: "bottom" },
145145
],
146-
default: defaultValue,
146+
defaultFunc: () => Serializer.getProperty("cover", questionName).defaultValue,
147147
};
148148
}
149149

@@ -163,7 +163,7 @@ Serializer.addClass(
163163
type: "buttongroup",
164164
name: "logoPosition",
165165
visibleIf: (obj) => obj.headerView === "basic",
166-
default: "left",
166+
defaultFunc: () => Serializer.getProperty("survey", "logoPosition").defaultValue,
167167
choices: [
168168
{ value: "left" },
169169
{ value: "right" }
@@ -173,7 +173,7 @@ Serializer.addClass(
173173
type: "spinedit",
174174
name: "height",
175175
visibleIf: (obj) => obj.headerView === "advanced",
176-
default: 0,
176+
defaultFunc: () => Serializer.getProperty("cover", "height").defaultValue,
177177
onPropertyEditorUpdate: function (obj: any, editor: any) {
178178
if (!!editor) {
179179
editor.unit = "px";
@@ -185,7 +185,7 @@ Serializer.addClass(
185185
type: "spinedit",
186186
name: "mobileHeight",
187187
visibleIf: (obj) => obj.headerView === "advanced",
188-
default: 0,
188+
defaultFunc: () => Serializer.getProperty("cover", "mobileHeight").defaultValue,
189189
onPropertyEditorUpdate: function (obj: any, editor: any) {
190190
if (!!editor) {
191191
editor.unit = "px";
@@ -197,7 +197,7 @@ Serializer.addClass(
197197
type: "buttongroup",
198198
name: "inheritWidthFrom",
199199
visibleIf: (obj) => obj.headerView === "advanced",
200-
default: "survey",
200+
defaultFunc: () => Serializer.getProperty("cover", "inheritWidthFrom").defaultValue,
201201
choices: [
202202
{ value: "survey" },
203203
{ value: "container" }
@@ -207,7 +207,7 @@ Serializer.addClass(
207207
type: "spinedit",
208208
name: "textAreaWidth",
209209
visibleIf: (obj) => obj.headerView === "advanced",
210-
default: 0,
210+
defaultFunc: () => Serializer.getProperty("cover", "textAreaWidth").defaultValue,
211211
onPropertyEditorUpdate: function (obj: any, editor: any) {
212212
if (!!editor) {
213213
editor.unit = "px";
@@ -260,7 +260,7 @@ Serializer.addClass(
260260
{ value: "contain" },
261261
{ value: "tile" },
262262
],
263-
default: "cover",
263+
defaultFunc: () => Serializer.getProperty("cover", "backgroundImageFit").defaultValue,
264264
visibleIf: (obj) => obj.headerView === "advanced",
265265
onPropertyEditorUpdate: function (obj: any, editor: any) {
266266
if (!!editor) {
@@ -272,7 +272,13 @@ Serializer.addClass(
272272
type: "spinedit",
273273
name: "backgroundImageOpacity",
274274
visibleIf: (obj) => obj.headerView === "advanced",
275-
default: 100,
275+
defaultFunc: () => {
276+
const defaultValue = Serializer.getProperty("cover", "backgroundImageOpacity").defaultValue;
277+
if(defaultValue !== undefined && defaultValue !== null) {
278+
return defaultValue * 100;
279+
}
280+
return defaultValue;
281+
},
276282
onPropertyEditorUpdate: function (obj: any, editor: any) {
277283
if (!!editor) {
278284
editor.unit = "%";
@@ -296,12 +302,12 @@ Serializer.addClass(
296302
}
297303
},
298304

299-
getHorizontalAlignment("logoPositionX", "left"),
300-
getVerticalAlignment("logoPositionY", "bottom"),
301-
getHorizontalAlignment("titlePositionX", "left"),
302-
getVerticalAlignment("titlePositionY", "bottom"),
303-
getHorizontalAlignment("descriptionPositionX", "left"),
304-
getVerticalAlignment("descriptionPositionY", "bottom"),
305+
getHorizontalAlignment("logoPositionX"),
306+
getVerticalAlignment("logoPositionY"),
307+
getHorizontalAlignment("titlePositionX"),
308+
getVerticalAlignment("titlePositionY"),
309+
getHorizontalAlignment("descriptionPositionX"),
310+
getVerticalAlignment("descriptionPositionY"),
305311
]);
306312

307313
Serializer.addProperties("header", [

packages/survey-creator-core/tests/tabs/theme-model-property-grid.tests.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -841,7 +841,7 @@ test("headerViewContainer init state", (): any => {
841841
"backgroundImageFit": "cover",
842842
"backgroundImageOpacity": 100,
843843
"logoPositionX": "left",
844-
"logoPositionY": "bottom",
844+
"logoPositionY": "top",
845845
"titlePositionX": "left",
846846
"titlePositionY": "bottom",
847847
"descriptionPositionX": "left",

0 commit comments

Comments
 (0)