Skip to content

Commit

Permalink
Fix JS code style
Browse files Browse the repository at this point in the history
  • Loading branch information
MarekSuchanek committed Jan 5, 2020
1 parent 2a90da4 commit b06b8f9
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 17 deletions.
2 changes: 1 addition & 1 deletion src/main/resources/module/scripts/dialogs/about-dialog.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* global $, DOM, DialogSystem */
/* global DOM, DialogSystem */

class MetadataAboutDialog {
constructor(type, specs, callbackFn, prefill) {
Expand Down
27 changes: 17 additions & 10 deletions src/main/resources/module/scripts/dialogs/metadata-form-dialog.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* global $, DOM, DialogSystem, Refine, MetadataApiClient, StoreDataDialog */
/* global DOM, DialogSystem, Refine, MetadataApiClient, StoreDataDialog */

class MetadataFormDialog {
constructor(specs, callbackFn, prefill) {
Expand Down Expand Up @@ -65,7 +65,7 @@ class MetadataFormDialog {

setValue(fieldId, value) {
const input = this.elements.metadataForm.find(`#${fieldId}`);
if (input != null) {
if (input !== null) {
if (input.is(":radio") && value === true) {
input.prop("checked", true);
} else {
Expand Down Expand Up @@ -226,24 +226,31 @@ class MetadataFormDialog {
});
}

makeInputField(field) {
const input = $(field.type === "text" ? "<textarea>" : "<input>")
.attr("id", field.id)
.attr("name", field.id)
.attr("type", "text")
.attr("title", $.i18n(`metadata/${this.specs.id}/${field.id}/description`))
.prop("required", field.required);

handleInputType(field, input) {
if (field.hidden) {
input.attr("type", "hidden");
} else if (field.type === "iri") {
input
.attr("type", "uri")
.attr("placeholder", "http://");
}
}

handleTypehints(field, input) {
if (field.typehints) {
this.makeDataList(field, input);
}
}

makeInputField(field) {
let input = $(field.type === "text" ? "<textarea>" : "<input>")
.attr("id", field.id)
.attr("name", field.id)
.attr("type", "text")
.attr("title", $.i18n(`metadata/${this.specs.id}/${field.id}/description`))
.prop("required", field.required);
this.handleInputType(field, input);
this.handleTypehints(field, input);
return input;
}

Expand Down
6 changes: 3 additions & 3 deletions src/main/resources/module/scripts/dialogs/post-fdp-dialog.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* global $, DOM, DialogSystem, MetadataHelpers, MetadataFormDialog, MetadataSpecs, MetadataApiClient */
/* global DOM, DialogSystem, MetadataHelpers, MetadataFormDialog, MetadataSpecs, MetadataApiClient */

class PostFdpDialog {

Expand Down Expand Up @@ -177,7 +177,7 @@ class PostFdpDialog {
}

preparePrefill() {
if (this.settings.has("metadata") && this.settings.get("metadata") != null) {
if (this.settings.has("metadata") && this.settings.get("metadata") !== null) {
this.prefill = new Map(Object.entries(this.settings.get("metadata")));
}
}
Expand Down Expand Up @@ -392,7 +392,7 @@ class PostFdpDialog {
} else {
formDialog.displayError(result.exceptionName, result.exception);
}
}
};
}

// show parts
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* global $, DOM, DialogSystem, MetadataHelpers, MetadataStorageSpecs */
/* global DOM, DialogSystem, MetadataHelpers, MetadataStorageSpecs */

class StoreDataDialog {

Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/module/scripts/helpers.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* global $, theProject, Refine, window, DialogSystem */
/* global theProject, Refine, DialogSystem */

let MetadataHelpers = {
moduleName: "metadata"
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/module/scripts/menu-bar-extension.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* global $, lang, ExtensionBar, PostFdpDialog, StoreDataDialog, MetadataAboutDialog, MetadataHelpers */
/* global lang, ExtensionBar, PostFdpDialog, StoreDataDialog, MetadataAboutDialog, MetadataHelpers */

// Load the localization file
var dictionary = {};
Expand Down

0 comments on commit b06b8f9

Please sign in to comment.