Skip to content

Commit

Permalink
disable warnings button
Browse files Browse the repository at this point in the history
  • Loading branch information
dlopezalvas committed Sep 4, 2023
1 parent 7741eac commit d29858d
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 0 deletions.
7 changes: 7 additions & 0 deletions app/components/challenge-workspace-buttons.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Component from '@ember/component';
import { inject as service } from '@ember/service';
import { changeWarningVisibility } from '../utils/blocks';

const VERSION_DEL_FORMATO_DE_ARCHIVO = 2;

Expand All @@ -10,6 +11,7 @@ export default Component.extend({
xml: null,
store: service(),
deleteDialogIsOpen: false,
warningsDisabled: true,
platform: service(),
intl: service(),

Expand Down Expand Up @@ -88,6 +90,11 @@ export default Component.extend({
this.fileInput().click();
},

changeWarningVisibility() {
changeWarningVisibility(!this.get('warningsDisabled'))
this.set('warningsDisabled', !this.get('warningsDisabled'))
},

guardarSolucion() {
let activityName = this.get("actividad.nombre");
let fileName = `${activityName}.spbq`;
Expand Down
1 change: 1 addition & 0 deletions app/templates/components/challenge-workspace-buttons.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<span class="flex"></span>
<input type='file' id="cargarActividadInput" accept=".spbq" class="hidden" />
<a id="placeholder" class="hidden">..</a>
<Button @tooltip={{if this.warningsDisabled (t "components.challengeWorkspaceButtons.warnings.disable") (t "components.challengeWorkspaceButtons.warnings.enable") }} @isMini={{true}} @isFab={{true}} @isRaised={{true}} @onClick={{action "changeWarningVisibility"}}>{{paper-icon (if this.warningsDisabled "speaker_notes_off" "speaker_notes")}}</Button>
<Button @tooltip={{t "components.challengeWorkspaceButtons.open" }} @isMini={{true}} @isFab={{true}} @isRaised={{true}} @onClick={{action "abrirSolucion"}}>{{paper-icon "folder"}}</Button>
<Button @tooltip={{t "components.challengeWorkspaceButtons.save"}} @isMini={{true}} @isFab={{true}} @isRaised={{true}} @onClick={{action "guardarSolucion"}}>{{paper-icon "save"}}</Button>
<Button @tooltip={{t "components.challengeWorkspaceButtons.delete"}} @isMini={{true}} @isFab={{true}} @isRaised={{true}} @onClick={{action (mut this.deleteDialogIsOpen) true}}>{{paper-icon "delete"}}</Button>
Expand Down
4 changes: 4 additions & 0 deletions app/utils/blocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,10 @@ export function addError(block, message, index) {
addWarningToBlock(block, '★', message, index, 'red')
}

export function changeWarningVisibility(visible) {
Blockly.getMainWorkspace().getAllBlocks().forEach(b => b.warning && b.warning.setVisible(visible))
}

function textWasChanged(fieldName, event) {
return event.element === 'field' && event.name === fieldName && (event.oldValue !== event.newValue)
}
Expand Down
3 changes: 3 additions & 0 deletions translations/components/en-us.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ challengeWorkspaceButtons:
notASolution: This file does not have a Pilas Bloques solution.
wrongActivity: 'Be careful! The file indicates that it is from another challenge ({activity}). It will be loaded anyways, but it could fail.'
oldVersion: 'Be careful! The file indicates that it is from an older version. It will be loaded anyways, but we suggest that you solve the challenge again and save the solution in a new file.'
warnings:
disable: 'Disable warnings'
enable: 'Enable warnings'
footer:
version: 'Version:'
problem: Any problem with this exercise?
Expand Down
3 changes: 3 additions & 0 deletions translations/components/es-ar.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ challengeWorkspaceButtons:
notASolution: Este archivo no tiene una solución de Pilas Bloques.
wrongActivity: '¡Cuidado! El archivo indica que es para otra actividad ({activity}). Se cargará de todas formas, pero puede fallar.'
oldVersion: '¡Cuidado! El archivo indica que es de una versión anterior. Se cargará de todas formas, pero te sugerimos que resuelvas nuevamente el ejercicio y guardes un nuevo archivo.'
warnings:
disable: 'Desactivar advertencias'
enable: 'Activar advertencias'
footer:
version: 'Versión:'
problem: ¿Algún problema con este ejercicio?
Expand Down
3 changes: 3 additions & 0 deletions translations/components/pt-br.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ challengeWorkspaceButtons:
notASolution: Este arquivo não tem uma solução da Pilas Blocos.
wrongActivity: Cuidado! O arquivo indica que é para outra atividade ({activity}). Será carregado de cualquer forma, mas pode falhar.
oldVersion: Cuidado! O arquivo indica que é de uma versão anterior. Será carregado de qualquer forma, mas sugerimos que resolva novamente o exercício e guarde um novo arquivo.
warnings:
disable: 'Desativar avisos'
enable: 'Ativar avisos'
footer:
version: 'Versão:'
problem: Problemas com este exercício?
Expand Down

0 comments on commit d29858d

Please sign in to comment.