mirror of
https://github.com/avatao-content/frontend-tutorial-framework
synced 2025-01-16 05:51:55 +00:00
Refactor save! saving... saved! truth table to single string :D
This commit is contained in:
parent
d0a35b53d3
commit
13e60e5d98
@ -3,12 +3,13 @@
|
|||||||
class="btn btn-secondary"
|
class="btn btn-secondary"
|
||||||
[class.active]="filename === file"
|
[class.active]="filename === file"
|
||||||
[class.disabled]="filename === file"
|
[class.disabled]="filename === file"
|
||||||
(click)="selectCode(file); requestCode()">
|
(click)="selectCode(file); requestCode()"
|
||||||
|
[disabled]="filename === file">
|
||||||
{{file}}
|
{{file}}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div (textChanged)="saved = false"
|
<div (textChanged)="saveButtonState = 'DIRTY'"
|
||||||
ace-editor
|
ace-editor
|
||||||
[(text)]="code"
|
[(text)]="code"
|
||||||
[(mode)]="language"
|
[(mode)]="language"
|
||||||
@ -18,17 +19,12 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<button (click)="sendCode()"
|
<button (click)="sendCode()"
|
||||||
[disabled]="saving === true"
|
[disabled]="saveButtonState === 'SAVING'"
|
||||||
type="submit"
|
type="submit"
|
||||||
class="btn btn-secondary"
|
class="btn btn-secondary"
|
||||||
[class.btn-success]="saved === true"
|
[class.btn-success]="saveButtonState === 'SAVED'"
|
||||||
[class.btn-warning]="saving === true"
|
[class.btn-warning]="saveButtonState === 'SAVING'"
|
||||||
[class.disabled]="saving === true"
|
[class.disabled]="saveButtonState === 'SAVING'"
|
||||||
><span *ngIf="saved === false && saving === false">Save</span>
|
><span *ngIf="saveButtonState === 'DIRTY'">Save!</span>
|
||||||
<span *ngIf="saved === true && saving === false">Saved!</span>
|
<span *ngIf="saveButtonState === 'SAVED'">Saved!</span>
|
||||||
<span *ngIf="saved === false && saving === true">Saving...</span></button>
|
<span *ngIf="saveButtonState === 'SAVING'">Saving...</span></button>
|
||||||
|
|
||||||
<span *ngIf="saved === true">Saved</span>
|
|
||||||
<span *ngIf="saving === true">Saving</span>
|
|
||||||
<span *ngIf="saved === false">Not Saved</span>
|
|
||||||
<span *ngIf="saving === false">Not Saving</span>
|
|
||||||
|
@ -20,8 +20,7 @@ export class WebideComponent implements OnInit {
|
|||||||
language = 'javascript';
|
language = 'javascript';
|
||||||
theme = 'monokai';
|
theme = 'monokai';
|
||||||
files: string[];
|
files: string[];
|
||||||
saved = false;
|
saveButtonState = 'DIRTY';
|
||||||
saving = false;
|
|
||||||
|
|
||||||
constructor(private webSocketService: WebSocketService) { }
|
constructor(private webSocketService: WebSocketService) { }
|
||||||
|
|
||||||
@ -31,7 +30,7 @@ export class WebideComponent implements OnInit {
|
|||||||
this.code = event.data.content;
|
this.code = event.data.content;
|
||||||
this.language = event.data.language;
|
this.language = event.data.language;
|
||||||
this.files = event.data.files;
|
this.files = event.data.files;
|
||||||
if (event.data.command === 'write') { this.saved = true; this.saving = false; }
|
if (event.data.command === 'write') { this.saveButtonState = 'SAVED'; }
|
||||||
});
|
});
|
||||||
this.requestCode();
|
this.requestCode();
|
||||||
}
|
}
|
||||||
@ -41,8 +40,7 @@ export class WebideComponent implements OnInit {
|
|||||||
'command': 'write',
|
'command': 'write',
|
||||||
'content': this.code
|
'content': this.code
|
||||||
});
|
});
|
||||||
this.saving = true;
|
this.saveButtonState = 'SAVING';
|
||||||
this.saved = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
requestCode() {
|
requestCode() {
|
||||||
|
Loading…
Reference in New Issue
Block a user