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';
3030export { ImageManager } from './image-manager' ;
3131export { ImagePicker } from './image-picker' ;
3232export { ListSortControl } from './list-sort-control' ;
33+ export { LoadingButton } from './loading-button' ;
3334export { MarkdownEditor } from './markdown-editor' ;
3435export { NewUserPassword } from './new-user-password' ;
3536export { 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;
106106 }
107107}
108108
109+ .inline.block .loading-container {
110+ margin : $-xs $-s ;
111+ }
112+
109113.skip-to-content-link {
110114 position : fixed ;
111115 top : -52px ;
Original file line number Diff line number Diff line change 5959 ] )
6060 @endif
6161
62- <div class =" text-right " >
62+ <div class =" flex-container-row items-center justify-flex-end " >
6363 <a href =" {{ url (' /import' ) } }" class =" button outline" >{{ trans (' common.cancel' ) } } </a >
6464 <div component =" dropdown" class =" inline block mx-s" >
6565 <button refs =" dropdown@toggle"
@@ -72,7 +72,7 @@ class="button outline">{{ trans('common.delete') }}</button>
7272 <button type =" submit" form =" import-delete-form" class =" text-link small text-item" >{{ trans (' common.confirm' ) } } </button >
7373 </div >
7474 </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 >
7676 </div >
7777 </form >
7878 </main >
You can’t perform that action at this time.
0 commit comments