File tree Expand file tree Collapse file tree 4 files changed +45
-2
lines changed Expand file tree Collapse file tree 4 files changed +45
-2
lines changed Original file line number Diff line number Diff line change @@ -30,6 +30,7 @@ export {HeaderMobileToggle} from './header-mobile-toggle';
30
30
export { ImageManager } from './image-manager' ;
31
31
export { ImagePicker } from './image-picker' ;
32
32
export { ListSortControl } from './list-sort-control' ;
33
+ export { LoadingButton } from './loading-button' ;
33
34
export { MarkdownEditor } from './markdown-editor' ;
34
35
export { NewUserPassword } from './new-user-password' ;
35
36
export { Notification } from './notification' ;
Original file line number Diff line number Diff line change
1
+ import { Component } from "./component.js" ;
2
+ import { showLoading } from "../services/dom" ;
3
+ import { el } from "../wysiwyg/utils/dom" ;
4
+
5
+ /**
6
+ * Loading button.
7
+ * Shows a loading indicator and disables the button when the button is clicked,
8
+ * or when the form attached to the button is submitted.
9
+ */
10
+ export class LoadingButton extends Component {
11
+
12
+ protected button ! : HTMLButtonElement ;
13
+ protected loadingEl : HTMLDivElement | null = null ;
14
+
15
+ setup ( ) {
16
+ this . button = this . $el as HTMLButtonElement ;
17
+ const form = this . button . form ;
18
+
19
+ const action = ( ) => {
20
+ setTimeout ( ( ) => this . showLoadingState ( ) , 10 )
21
+ } ;
22
+
23
+ this . button . addEventListener ( 'click' , action ) ;
24
+ if ( form ) {
25
+ form . addEventListener ( 'submit' , action ) ;
26
+ }
27
+ }
28
+
29
+ showLoadingState ( ) {
30
+ this . button . disabled = true ;
31
+
32
+ if ( ! this . loadingEl ) {
33
+ this . loadingEl = el ( 'div' , { class : 'inline block' } ) as HTMLDivElement ;
34
+ showLoading ( this . loadingEl ) ;
35
+ this . button . after ( this . loadingEl ) ;
36
+ }
37
+ }
38
+ }
Original file line number Diff line number Diff line change @@ -106,6 +106,10 @@ $loadingSize: 10px;
106
106
}
107
107
}
108
108
109
+ .inline.block .loading-container {
110
+ margin : $-xs $-s ;
111
+ }
112
+
109
113
.skip-to-content-link {
110
114
position : fixed ;
111
115
top : -52px ;
Original file line number Diff line number Diff line change 59
59
] )
60
60
@endif
61
61
62
- <div class =" text-right " >
62
+ <div class =" flex-container-row items-center justify-flex-end " >
63
63
<a href =" {{ url (' /import' ) } }" class =" button outline" >{{ trans (' common.cancel' ) } } </a >
64
64
<div component =" dropdown" class =" inline block mx-s" >
65
65
<button refs =" dropdown@toggle"
@@ -72,7 +72,7 @@ class="button outline">{{ trans('common.delete') }}</button>
72
72
<button type =" submit" form =" import-delete-form" class =" text-link small text-item" >{{ trans (' common.confirm' ) } } </button >
73
73
</div >
74
74
</div >
75
- <button type =" submit" class =" button" >{{ trans (' entities.import_run' ) } } </button >
75
+ <button component = " loading-button " type =" submit" class =" button" >{{ trans (' entities.import_run' ) } } </button >
76
76
</div >
77
77
</form >
78
78
</main >
You can’t perform that action at this time.
0 commit comments