Skip to content

Commit

Permalink
lib: fix download buttons
Browse files Browse the repository at this point in the history
Fixes #2
  • Loading branch information
DylanVanAssche committed Feb 2, 2022
1 parent 8944065 commit 55833a9
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

### Fixed
- Typo: getAmountOfDateEditors renamed to getNumberOfDataEditors (see [issue 3](https://github.com/RMLio/matey/issues/2)).
- Make download buttons work again (see [issue 2](https://github.com/RMLio/matey/issues/2))

## [1.0.2] - 2022-01-24

Expand Down
23 changes: 23 additions & 0 deletions lib/editor-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,22 @@ module.exports = class EditorManager {
return activeEditor;
}

/**
* Returns the ioutput editor that is currently active in the page.
* @returns {Object} object that contains information about the active editor
*/
getActiveOutputEditor() {
let activeEditor = null;

this.outputEditors.forEach(outputEditor => {
if (outputEditor.elem.hasClass('active')) {
activeEditor = outputEditor;
}
});

return activeEditor;
}

/**
* Sets the content of the RML editor
* @param {String} rml - the rml to be placed in the editor
Expand Down Expand Up @@ -315,6 +331,13 @@ module.exports = class EditorManager {
return this.rmlEditor.getValue();
}

/**
@returns {String} text inside YARRRML editor
*/
getYARRRML() {
return this.inputEditor.getValue();
}

/**
@returns {String} text inside active data editor
*/
Expand Down
9 changes: 6 additions & 3 deletions lib/front.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,15 +108,18 @@ module.exports = class Front {
});

$('#yarrrml-dl-matey').on('click', () => {
downloadString(this.matey.editor.getValue(), 'text', 'yarrrml.yaml');
downloadString(this.matey.editorManager.getYARRRML(), 'text', 'yarrrml.yaml');
});

$('#turtle-dl-matey').on('click', () => {
downloadString(this.matey.outputEditor.getValue(), 'text/turtle', 'output.ttl');
const activeEditor = this.matey.editorManager.getActiveOutputEditor();
console.log(activeEditor)

downloadString(activeEditor.editor.getValue(), 'text', activeEditor.path);
});

$('#rml-dl-matey').on('click', () => {
downloadString(this.matey.rmlEditor.getValue(), 'text/turtle', 'output.rml.ttl');
downloadString(this.matey.editorManager.getRML(), 'text/turtle', 'output.rml.ttl');
});
}

Expand Down

0 comments on commit 55833a9

Please sign in to comment.