mirror of
				https://github.com/avatao-content/frontend-tutorial-framework
				synced 2025-11-04 12:22:54 +00:00 
			
		
		
		
	Remove 'Save' button from frontend
This commit is contained in:
		@@ -9,7 +9,7 @@
 | 
			
		||||
  </button>
 | 
			
		||||
</div>
 | 
			
		||||
 | 
			
		||||
<div (keyup)="setSaveButtonState('DIRTY'); setDeployButtonState('TODEPLOY'); resetAutoSaveCountdown()"
 | 
			
		||||
<div (keyup)="setCodeState('DIRTY'); setDeployButtonState('TODEPLOY'); resetAutoSaveCountdown()"
 | 
			
		||||
  ace-editor
 | 
			
		||||
  [(text)]="code"
 | 
			
		||||
  [mode]="language"
 | 
			
		||||
@@ -21,7 +21,7 @@
 | 
			
		||||
<div class="btn-group flex-wrap">
 | 
			
		||||
<button type="submit"
 | 
			
		||||
        class="btn btn-secondary"
 | 
			
		||||
        (click)="sendCode(); deployCode()"
 | 
			
		||||
        (click)="sendCodeIfDirty(); deployCode()"
 | 
			
		||||
        [disabled]="deployButtonState === 'DEPLOYING' || deployButtonState === 'DEPLOYED'"
 | 
			
		||||
        [class.btn-success]="deployButtonState === 'DEPLOYED'"
 | 
			
		||||
        [class.btn-info]="deployButtonState === 'DEPLOYING'"
 | 
			
		||||
@@ -29,14 +29,4 @@
 | 
			
		||||
><span *ngIf="deployButtonState === 'TODEPLOY'">Deploy</span>
 | 
			
		||||
 <span *ngIf="deployButtonState === 'DEPLOYED'">Deploy</span>
 | 
			
		||||
 <span *ngIf="deployButtonState === 'DEPLOYING'"><div class="loader"></div>Reloading app...</span></button>
 | 
			
		||||
<button (click)="sendCode()"
 | 
			
		||||
        [disabled]="saveButtonState === 'SAVING' || saveButtonState === 'SAVED'"
 | 
			
		||||
        type="submit"
 | 
			
		||||
        class="btn btn-secondary"
 | 
			
		||||
        [class.btn-success]="saveButtonState === 'SAVED'"
 | 
			
		||||
        [class.btn-warning]="saveButtonState === 'SAVING'"
 | 
			
		||||
        [class.disabled]="saveButtonState === 'SAVING' || saveButtonState === 'SAVED'"
 | 
			
		||||
><span *ngIf="saveButtonState === 'DIRTY'">Save</span>
 | 
			
		||||
 <span *ngIf="saveButtonState === 'SAVED'">Save</span>
 | 
			
		||||
 <span *ngIf="saveButtonState === 'SAVING'">Saving...</span></button>
 | 
			
		||||
</div>
 | 
			
		||||
 
 | 
			
		||||
@@ -33,7 +33,7 @@ export class WebideComponent implements OnInit {
 | 
			
		||||
  language = 'javascript';
 | 
			
		||||
  theme = 'monokai';
 | 
			
		||||
  files: string[];
 | 
			
		||||
  saveButtonState = 'SAVED';
 | 
			
		||||
  codeState = 'SAVED';
 | 
			
		||||
  deployButtonState = 'DEPLOYED';
 | 
			
		||||
  autosave = null;
 | 
			
		||||
  command_handlers = {'reload': this.reloadHandler.bind(this),
 | 
			
		||||
@@ -78,11 +78,11 @@ export class WebideComponent implements OnInit {
 | 
			
		||||
 | 
			
		||||
  readHandler(data: SourceCode) {
 | 
			
		||||
    this.updateFileData(data);
 | 
			
		||||
    this.saveButtonState = 'SAVED';
 | 
			
		||||
    this.setCodeState('SAVED');
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  writeHandler() {
 | 
			
		||||
    this.saveButtonState = 'SAVED';
 | 
			
		||||
    this.setCodeState('SAVED');
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  resetAutoSaveCountdown() {
 | 
			
		||||
@@ -93,15 +93,17 @@ export class WebideComponent implements OnInit {
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  tabSwitchButtonHandler(file) {
 | 
			
		||||
    if (this.saveButtonState === 'DIRTY') {
 | 
			
		||||
    if (this.codeState === 'DIRTY') {
 | 
			
		||||
      this.sendCodeContents();
 | 
			
		||||
    }
 | 
			
		||||
    this.selectCode(file);
 | 
			
		||||
    this.requestCode();
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  setSaveButtonState(state: string) {
 | 
			
		||||
    this.saveButtonState = state;
 | 
			
		||||
  setCodeState(state: string) {
 | 
			
		||||
    if (state.match('SAVED|DIRTY')) {
 | 
			
		||||
      this.codeState = state;
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  setDeployButtonState(state: string) {
 | 
			
		||||
@@ -113,15 +115,8 @@ export class WebideComponent implements OnInit {
 | 
			
		||||
    this.deployButtonState = 'DEPLOYING';
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  sendCode() {
 | 
			
		||||
    if (this.saveButtonState === 'DIRTY') {
 | 
			
		||||
      this.sendCodeContents();
 | 
			
		||||
      this.saveButtonState = 'SAVING';
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  sendCodeIfDirty() {
 | 
			
		||||
    if (this.saveButtonState === 'DIRTY') {
 | 
			
		||||
    if (this.codeState === 'DIRTY') {
 | 
			
		||||
      this.sendCodeContents();
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user