Skip to content

Commit

Permalink
Work for surveyjs/survey-creator#4435: Implement loading indicator in…
Browse files Browse the repository at this point in the history
… Knockout
  • Loading branch information
dk981234 committed Sep 5, 2023
1 parent 6405453 commit 3ebc292
Show file tree
Hide file tree
Showing 9 changed files with 61 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/defaultV2-theme/blocks/sd-element.scss
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
white-space: normal;

&::before {
content: "\200B";
content: "";
}
}
}
Expand Down
22 changes: 22 additions & 0 deletions src/defaultV2-theme/blocks/sd-loading-indicator.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
@keyframes rotationAnimation {
from {
rotate: 0deg;
}

to {
rotate: 360deg;
}
}

.sd-loading-indicator {
height: calcSize(6);

.sv-svg-icon {
height: calcSize(6);
width: calcSize(6);
animation-name: rotationAnimation;
animation-timing-function: linear;
animation-iteration-count: infinite;
animation-duration: 1s;
}
}
1 change: 1 addition & 0 deletions src/defaultV2-theme/defaultV2.fontless.scss
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
@import "blocks/sd-progress-toc.scss";
@import "blocks/sd-list.scss";
@import "blocks/sd-timer.scss";
@import "blocks/sd-loading-indicator.scss";
@import "../components-container.scss";
@import "../signaturepad.scss";
@import "./defaultV2.m600.scss";
Expand Down
1 change: 1 addition & 0 deletions src/entries/knockout-ui-model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ export { SurveyNavigationButton } from "../knockout/components/survey-actions/su
export * from "../knockout/components/paneldynamic-actions/paneldynamic-actions";
export * from "../knockout/components/brand-info/brand-info";
export * from "../knockout/components/notifier/notifier";
export * from "../knockout/components/loading-indicator/loading-indicator";

import * as ko from "knockout";
import { SurveyModel } from "survey-core";
Expand Down
11 changes: 11 additions & 0 deletions src/images/loading.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<div class="sd-loading-indicator">
<!-- ko component: { name: "sv-svg-icon", params: { iconName: 'icon-loading', size: 'auto' } } -->
<!-- /ko -->
</div>
14 changes: 14 additions & 0 deletions src/knockout/components/loading-indicator/loading-indicator.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import * as ko from "knockout";
const template = require("./loading-indicator.html");

export var LoadingIndicatorViewModel: any;

ko.components.register("sv-loading-indicator", {
viewModel: {
createViewModel: (
params: any,
componentInfo: any
) => {}
},
template: template
});
6 changes: 6 additions & 0 deletions src/knockout/templates/question-file.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@
<!-- /ko -->
<div data-bind="css: question.cssClasses.dragArea, event: { dragenter: question.ondragenter, dragover: question.ondragover, drop: question.ondrop, dragleave: question.ondragleave }">
<div data-bind="css: question.getFileDecoratorCss()">
<!-- ko if: question.isUploading -->
<!-- ko component: { name: "sv-loading-indicator" } -->
<!-- /ko -->
<!-- /ko -->
<!-- ko ifnot: question.isUploading -->
<span data-bind="css: question.cssClasses.dragAreaPlaceholder, text: question.renderedPlaceholder"></span>
<div data-bind="css: question.cssClasses.wrapper">
<!-- ko ifnot: isReadOnly -->
Expand All @@ -22,6 +27,7 @@
<span data-bind="css: question.cssClasses.noFileChosen, text: question.noFileChosenCaption"></span>
<!-- /ko -->
</div>
<!-- /ko -->
</div>
<!-- ko template: { name: 'survey-question-file-clean-button', data: {question: question, showRemoveButton: question.showRemoveButton} } --><!-- /ko -->
<!-- ko if: question.showPreview -->
Expand Down
2 changes: 1 addition & 1 deletion src/question_file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { Helpers } from "./helpers";
* [View Demo](https://surveyjs.io/form-library/examples/file-upload/ (linkStyle))
*/
export class QuestionFileModel extends Question {
private isUploading: boolean = false;
@property() public isUploading: boolean = false;
@property() isDragging: boolean = false;
/**
* An event that is raised after the upload state has changed.
Expand Down

0 comments on commit 3ebc292

Please sign in to comment.