Skip to content

Commit

Permalink
warnings disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
dlopezalvas committed Sep 5, 2023
1 parent d29858d commit ae600fa
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 12 deletions.
15 changes: 11 additions & 4 deletions app/components/challenge-workspace-buttons.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ export default Component.extend({
xml: null,
store: service(),
deleteDialogIsOpen: false,
warningsDisabled: true,
platform: service(),
intl: service(),

Expand Down Expand Up @@ -85,14 +84,22 @@ export default Component.extend({
input.value = null;
},

changeWarningVisibility(visible) {
changeWarningVisibility(visible)
this.set('warningsVisible', visible)
},

actions: {
abrirSolucion() {
this.fileInput().click();
},

enableWarnings() {
this.changeWarningVisibility(true)
},

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

guardarSolucion() {
Expand Down
3 changes: 2 additions & 1 deletion app/components/pilas-blockly.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export default Component.extend({
codigoJavascript: "", // Se carga como parametro
codigo: null,
challenge: null,
warningsVisible: true,

highlighter: service(),
availableBlocksValidator: service(),
Expand Down Expand Up @@ -436,7 +437,7 @@ export default Component.extend({
.filter(condition)
.forEach(({ declaration, description }, i) => {
getBlocks(declaration)
.forEach(block => addFeedback(block, description.asSuggestion, -i))
.forEach(block => addFeedback(block, description.asSuggestion, -i, this.get('warningsVisible')))
})
},

Expand Down
2 changes: 1 addition & 1 deletion app/templates/components/challenge-workspace-buttons.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +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={{if this.warningsVisible (t "components.challengeWorkspaceButtons.warnings.disable") (t "components.challengeWorkspaceButtons.warnings.enable")}} @isMini={{true}} @isFab={{true}} @isRaised={{true}} @onClick={{action (if this.warningsVisible "disableWarnings" "enableWarnings")}}>{{paper-icon (if this.warningsVisible "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
1 change: 1 addition & 0 deletions app/templates/components/pilas-blockly.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
<ChallengeWorkspaceButtons
@actividad={{this.challenge}}
@shouldUseFloatingMode={{this.shouldUseFloatingMode}}
@warningsVisible={{this.warningsVisible}}
@changeScreenMode={{this.changeScreenMode}}
@xml={{this.codigoActualEnFormatoXML}}
@setWorkspace={{action "setWorkspace"}}
Expand Down
13 changes: 7 additions & 6 deletions app/utils/blocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,19 +175,20 @@ const setWarningBubbleColour = (block, colour) => {
block.warning.setVisible = (visible) => { boundedSetVisible(visible); if (visible) block.warning.bubble_.setColour(colour) }
}

const addWarningToBlock = (block, itemChar, message, index, bubbleColour) => {
const addWarningToBlock = (block, itemChar, message, index, bubbleColour, visible = true) => {
const text = `${itemChar} ${lineWrap(message)}`
block.setWarningText(text, index)
setWarningBubbleColour(block, bubbleColour)
block.warning.setVisible(true)
block.warning.setVisible(visible)
}

export function addWarning(block, message, index) {
addWarningToBlock(block, '☆', message, index, 'yellow')
export function addWarning(block, message, index, visible) {
addWarningToBlock(block, '☆', message, index, 'yellow', visible)
}

export function addError(block, message, index) {
addWarningToBlock(block, '★', message, index, 'red')
export function addError(block, message, index, visible) {
console.log(visible)
addWarningToBlock(block, '★', message, index, 'red', visible)
}

export function changeWarningVisibility(visible) {
Expand Down

0 comments on commit ae600fa

Please sign in to comment.