-
Notifications
You must be signed in to change notification settings - Fork 373
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue/4895-Add-an-option-to-expand-and-collapse-panels-on-a-design-su…
…rface (#5631) * #4895 Add an option to expand and collapse panels on a design surface Fixes #4895 * #4895 - fixed buttons * #4895 panel and question expand/collapse Fixes #4895 * #4895 - saving expanded collapsed state * #4895 - all platforms and v-test * #4895 - styles, tests * #4895 do not grow collapsed questions in row Fixes #4895 * #4895 fix knockout focus Fixes #4895 * #4895 - add option * Rename the property and add a description draft * fixed unit and knockout v-tests * #4895 - rename property * #4895 - fixed markup * #4895 - fix f-test * #4895 - update screenshots * #4895 - fix f-test * #4895 - fix f-test * #4895 - fixed v-test --------- Co-authored-by: Aleksey Novikov <[email protected]> Co-authored-by: RomanTsukanov <[email protected]>
- Loading branch information
1 parent
2d758bd
commit 590f295
Showing
29 changed files
with
454 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
packages/survey-creator-core/src/components/tabs/designer-state-manager.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import { SurveyElement, SurveyModel } from "survey-core"; | ||
class ElementState { | ||
collapsed: boolean = false; | ||
} | ||
|
||
interface ElementStateMap { | ||
[key: string]: ElementState; | ||
} | ||
|
||
export class DesignerStateManager { | ||
private elementState: ElementStateMap = {}; | ||
private pageState: ElementStateMap = {}; | ||
private getStateMapForElement(element: SurveyElement) { | ||
return (element && element.isPage) ? this.pageState : this.elementState; | ||
} | ||
|
||
private onQuestionAddedHandler = (sender, opts): void => { | ||
this.elementState[opts.question.name] = new ElementState(); | ||
} | ||
private onPageAddedHandler = (sender, opts): void => { | ||
this.pageState[opts.page.name] = new ElementState(); | ||
} | ||
private onPanelAddedHandler = (sender, opts): void => { | ||
this.elementState[opts.panel.name] = new ElementState(); | ||
} | ||
initForSurvey(survey: SurveyModel) { | ||
survey.onQuestionAdded.add(this.onQuestionAddedHandler); | ||
survey.onPageAdded.add(this.onPageAddedHandler); | ||
survey.onPanelAdded.add(this.onPanelAddedHandler); | ||
} | ||
initForElement(element: SurveyElement): void { | ||
if (!element) return; | ||
const stateMap = this.getStateMapForElement(element); | ||
element.registerFunctionOnPropertyValueChanged( | ||
"name", | ||
(newName) => { | ||
delete stateMap[element.name]; | ||
stateMap[newName] = new ElementState(); | ||
}, | ||
"designerStateManager" | ||
); | ||
} | ||
getElementState(element: SurveyElement): ElementState { | ||
const stateMap = this.getStateMapForElement(element); | ||
const name = element.name; | ||
let state = stateMap[name]; | ||
if (state) return state; | ||
state = new ElementState(); | ||
stateMap[name] = new ElementState(); | ||
return state; | ||
} | ||
constructor() { | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions
10
packages/survey-creator-core/src/images/expand-v_16x16.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.