From 7e874ccc0568ab6d0d20ed9a5e79c018908d948f Mon Sep 17 00:00:00 2001 From: Anthony Sena Date: Wed, 9 Jan 2019 15:24:24 -0500 Subject: [PATCH] Baby steps towards editorconfig and eslint --- .editorconfig | 19 ++ .eslintrc.json | 46 +++ .jshintrc | 122 -------- js/const.js | 776 ++++++++++++++++++++++++------------------------- js/settings.js | 126 ++++---- package.json | 3 + 6 files changed, 519 insertions(+), 573 deletions(-) create mode 100644 .editorconfig create mode 100644 .eslintrc.json delete mode 100644 .jshintrc diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 000000000..473ccf5bc --- /dev/null +++ b/.editorconfig @@ -0,0 +1,19 @@ +# EditorConfig is awesome: https://EditorConfig.org + +# top-most EditorConfig file +root = true + +# Tab indentation +[*] +indent_style = tab +trim_trailing_whitespace = true + +# Additional file configuration +charset = utf-8 +insert_final_newline = true + +# The indent size used in the `package.json` file cannot be changed +# https://github.com/npm/npm/pull/3180#issuecomment-16336516 +[{*.yml,*.yaml,package.json}] +indent_style = space +indent_size = 2 diff --git a/.eslintrc.json b/.eslintrc.json new file mode 100644 index 000000000..4094f495c --- /dev/null +++ b/.eslintrc.json @@ -0,0 +1,46 @@ +{ + "env": { + "browser": true, + "es6": true + }, + "plugins": [ + "requirejs" + ], + "extends": [ + "eslint:recommended", + "plugin:requirejs/recommended" + ], + "parser": "babel-eslint", + "parserOptions": { + "ecmaVersion": 6 + }, + "rules": { + "indent": [ + "error", + "tab" + ], + "linebreak-style": [ + "error", + "windows" + ], + "quotes": [ + "error", + "double" + ], + "semi": [ + "error", + "always" + ] + }, + "overrides": [ + { + "files": [ + "settings.js" + ], + "rules": { + "no-unused-vars": "off", + "no-undef": "off" + } + } + ] +} diff --git a/.jshintrc b/.jshintrc deleted file mode 100644 index 56fbfc0e3..000000000 --- a/.jshintrc +++ /dev/null @@ -1,122 +0,0 @@ -{ - // -------------------------------------------------------------------- - // JSHint Configuration, Strict Edition - // -------------------------------------------------------------------- - // - // This is a options template for [JSHint][1], using [JSHint example][2] - // and [Ory Band's example][3] as basis and setting config values to - // be most strict: - // - // * set all enforcing options to true - // * set all relaxing options to false - // * set all environment options to false, except the browser value - // * set all JSLint legacy options to false - // - // [1]: http://www.jshint.com/ - // [2]: https://github.com/jshint/node-jshint/blob/master/example/config.json - // [3]: https://github.com/oryband/dotfiles/blob/master/jshintrc - // - // @author http://michael.haschke.biz/ - // @license http://unlicense.org/ - - // == Enforcing Options =============================================== - // - // These options tell JSHint to be more strict towards your code. Use - // them if you want to allow only a safe subset of JavaScript, very - // useful when your codebase is shared with a big number of developers - // with different skill levels. - "bitwise": true, // Prohibit bitwise operators (&, |, ^, etc.). - "curly": true, // Require {} for every new block or scope. - "eqeqeq": false, // Require triple equals i.e. `===`. - "forin": true, // Tolerate `for in` loops without `hasOwnPrototype`. - "immed": true, // Require immediate invocations to be wrapped in parens e.g. `( function(){}() );` - "latedef": true, // Prohibit variable use before definition. - "newcap": true, // Require capitalization of all constructor functions e.g. `new F()`. - "noarg": true, // Prohibit use of `arguments.caller` and `arguments.callee`. - "noempty": true, // Prohibit use of empty blocks. - "nonew": true, // Prohibit use of constructors for side-effects. - "plusplus": false, // Prohibit use of `++` & `--`. - "regexp": true, // Prohibit `.` and `[^...]` in regular expressions. - "undef": true, // Require all non-global variables be declared before they are used. - "strict": false, // Require `use strict` pragma in every file. - "trailing": true, // Prohibit trailing whitespaces. - - // == Relaxing Options ================================================ - // - // These options allow you to suppress certain types of warnings. Use - // them only if you are absolutely positive that you know what you are - // doing. - - "asi": false, // Tolerate Automatic Semicolon Insertion (no semicolons). - "boss": false, // Tolerate assignments inside if, for & while. Usually conditions & loops are for comparison, not assignments. - "debug": false, // Allow debugger statements e.g. browser breakpoints. - "eqnull": false, // Tolerate use of `== null`. - "evil": false, // Tolerate use of `eval`. - "expr": false, // Tolerate `ExpressionStatement` as Programs. - "funcscope": false, // Tolerate declarations of variables inside of control structures while accessing them later from the outside. - "globalstrict": false, // Allow global "use strict" (also enables 'strict'). - "iterator": false, // Allow usage of __iterator__ property. - "lastsemic": false, // Tolerat missing semicolons when the it is omitted for the last statement in a one-line block. - "laxbreak": false, // Tolerate unsafe line breaks e.g. `return [\n] x` without semicolons. - "laxcomma": false, // Suppress warnings about comma-first coding style. - "loopfunc": false, // Allow functions to be defined within loops. - "multistr": false, // Tolerate multi-line strings. - "onecase": false, // Tolerate switches with just one case. - "proto": false, // Tolerate __proto__ property. This property is deprecated. - "regexdash": false, // Tolerate unescaped last dash i.e. `[-...]`. - "scripturl": true, // Tolerate script-targeted URLs. - "smarttabs": false, // Tolerate mixed tabs and spaces when the latter are used for alignmnent only. - "shadow": false, // Allows re-define variables later in code e.g. `var x=1; x=2;`. - "sub": true, // Tolerate all forms of subscript notation besides dot notation e.g. `dict['key']` instead of `dict.key`. - "supernew": false, // Tolerate `new function () { ... };` and `new Object;`. - "validthis": false, // Tolerate strict violations when the code is running in strict mode and you use this in a non-constructor function. - - // == Environments ==================================================== - // - // These options pre-define global variables that are exposed by - // popular JavaScript libraries and runtime environments—such as - // browser or node.js. - "esversion": 5, - "browser": true, // Standard browser globals e.g. `window`, `document`. - "couch": false, // Enable globals exposed by CouchDB. - "devel": false, // Allow development statements e.g. `console.log();`. - "dojo": false, // Enable globals exposed by Dojo Toolkit. - "jquery": false, // Enable globals exposed by jQuery JavaScript library. - "mootools": false, // Enable globals exposed by MooTools JavaScript framework. - "node": false, // Enable globals available when code is running inside of the NodeJS runtime environment. - "nonstandard": false, // Define non-standard but widely adopted globals such as escape and unescape. - "prototypejs": false, // Enable globals exposed by Prototype JavaScript framework. - "rhino": false, // Enable globals available when your code is running inside of the Rhino runtime environment. - "wsh": false, // Enable globals available when your code is running as a script for the Windows Script Host. - - // == Formatting and Complexity ======================================= - // - // Indentation and max length work to naturally keep files small, - // editable, and with limited complexity. The other options are a - // strict way to enforce these. - - //"maxlen": 160, // Maximum line length, helps reduce cyclomatic complexity - //"indent": 2, // Specify indentation spacing - //"maxparams": 10, // Maximum number of formal parameters allowed per function - //"maxdepth": 4, // Maximum nested statement depth for a function - //"maxstatements": 33, // Maximum number of statements allowed per function - //"maxcomplexity": 15, // Maximum cyclomatic complexity of a function - // http://en.wikipedia.org/wiki/Cyclomatic_complexity - - // == JSLint Legacy =================================================== - // - // These options are legacy from JSLint. Aside from bug fixes they will - // not be improved in any way and might be removed at any point. - - "nomen": false, // Prohibit use of initial or trailing underbars in names. - "onevar": true, // Allow only one `var` statement per function. - "passfail": false, // Stop on first error. - "white": true, // Check against strict whitespace and indentation rules. - - "maxerr": 100, // Maximum errors before stopping. - "predef": [ // Extra globals. - "require", - "define", - "escape" - ] -} \ No newline at end of file diff --git a/js/const.js b/js/const.js index aa8d9fb04..d890e3912 100644 --- a/js/const.js +++ b/js/const.js @@ -1,411 +1,411 @@ define([ - 'knockout', - 'appConfig', - ], - ( - ko, - config, - ) => { + "knockout", + "appConfig", +], +( + ko, + config, +) => { - const minChartHeight = 300; - const treemapGradient = ["#c7eaff", "#6E92A8", "#1F425A"]; - const defaultDeciles = ["0-9", "10-19", "20-29", "30-39", "40-49", "50-59", "60-69", "70-79", "80-89", "90-99"]; - const relatedConceptsOptions = { - Facets: [{ - 'caption': 'Vocabulary', - 'binding': function (o) { - return o.VOCABULARY_ID; - } - }, { - 'caption': 'Standard Concept', - 'binding': function (o) { - return o.STANDARD_CONCEPT_CAPTION; - } - }, { - 'caption': 'Invalid Reason', - 'binding': function (o) { - return o.INVALID_REASON_CAPTION; - } - }, { - 'caption': 'Class', - 'binding': function (o) { - return o.CONCEPT_CLASS_ID; - } - }, { - 'caption': 'Domain', - 'binding': function (o) { - return o.DOMAIN_ID; - } - }, { - 'caption': 'Relationship', - 'binding': function (o) { - return o.RELATIONSHIPS.map((val) => val.RELATIONSHIP_NAME); - }, - isArray: true, - }, { - 'caption': 'Has Records', - 'binding': function (o) { - return parseInt(o.RECORD_COUNT.toString() - .replace(',', '')) > 0; - } - }, { - 'caption': 'Has Descendant Records', - 'binding': function (o) { - return parseInt(o.DESCENDANT_RECORD_COUNT.toString() - .replace(',', '')) > 0; - } - }, { - 'caption': 'Distance', - 'binding': function (o) { - return Math.max.apply(Math, o.RELATIONSHIPS.map(function (d) { - return d.RELATIONSHIP_DISTANCE; - })) - }, - }] - }; - - const getRelatedConceptsColumns = (sharedState) => [{ - title: '', - render: function (s, p, d) { - var css = ''; - var icon = 'fa-shopping-cart'; - if (sharedState.selectedConceptsIndex[d.CONCEPT_ID] == 1) { - css = ' selected'; - } - return ''; - }, - orderable: false, - searchable: false + const minChartHeight = 300; + const treemapGradient = ["#c7eaff", "#6E92A8", "#1F425A"]; + const defaultDeciles = ["0-9", "10-19", "20-29", "30-39", "40-49", "50-59", "60-69", "70-79", "80-89", "90-99"]; + const relatedConceptsOptions = { + Facets: [{ + "caption": "Vocabulary", + "binding": function (o) { + return o.VOCABULARY_ID; + } }, { - title: 'Id', - data: 'CONCEPT_ID' + "caption": "Standard Concept", + "binding": function (o) { + return o.STANDARD_CONCEPT_CAPTION; + } }, { - title: 'Code', - data: 'CONCEPT_CODE' + "caption": "Invalid Reason", + "binding": function (o) { + return o.INVALID_REASON_CAPTION; + } }, { - title: 'Name', - data: 'CONCEPT_NAME', - render: function (s, p, d) { - var valid = d.INVALID_REASON_CAPTION == 'Invalid' ? 'invalid' : ''; - return '' + d.CONCEPT_NAME + ''; + "caption": "Class", + "binding": function (o) { + return o.CONCEPT_CLASS_ID; } }, { - title: 'Class', - data: 'CONCEPT_CLASS_ID' + "caption": "Domain", + "binding": function (o) { + return o.DOMAIN_ID; + } + }, { + "caption": "Relationship", + "binding": function (o) { + return o.RELATIONSHIPS.map((val) => val.RELATIONSHIP_NAME); + }, + isArray: true, }, { - title: 'Standard Concept Caption', - data: 'STANDARD_CONCEPT_CAPTION', - visible: false + "caption": "Has Records", + "binding": function (o) { + return parseInt(o.RECORD_COUNT.toString() + .replace(",", "")) > 0; + } }, { - title: 'RC', - data: 'RECORD_COUNT', - className: 'numeric' + "caption": "Has Descendant Records", + "binding": function (o) { + return parseInt(o.DESCENDANT_RECORD_COUNT.toString() + .replace(",", "")) > 0; + } }, { - title: 'DRC', - data: 'DESCENDANT_RECORD_COUNT', - className: 'numeric' + "caption": "Distance", + "binding": function (o) { + return Math.max.apply(Math, o.RELATIONSHIPS.map(function (d) { + return d.RELATIONSHIP_DISTANCE; + })); + }, + }] + }; + + const getRelatedConceptsColumns = (sharedState) => [{ + title: "", + render: function (s, p, d) { + var css = ""; + var icon = "fa-shopping-cart"; + if (sharedState.selectedConceptsIndex[d.CONCEPT_ID] == 1) { + css = " selected"; + } + return ""; + }, + orderable: false, + searchable: false + }, { + title: "Id", + data: "CONCEPT_ID" + }, { + title: "Code", + data: "CONCEPT_CODE" + }, { + title: "Name", + data: "CONCEPT_NAME", + render: function (s, p, d) { + var valid = d.INVALID_REASON_CAPTION == "Invalid" ? "invalid" : ""; + return "" + d.CONCEPT_NAME + ""; + } + }, { + title: "Class", + data: "CONCEPT_CLASS_ID" + }, { + title: "Standard Concept Caption", + data: "STANDARD_CONCEPT_CAPTION", + visible: false + }, { + title: "RC", + data: "RECORD_COUNT", + className: "numeric" + }, { + title: "DRC", + data: "DESCENDANT_RECORD_COUNT", + className: "numeric" + }, { + title: "Domain", + data: "DOMAIN_ID" + }, { + title: "Vocabulary", + data: "VOCABULARY_ID" + }, { + title: "Ancestor", + data: "ANCESTORS" + }]; + const relatedSourcecodesOptions = { + Facets: [{ + "caption": "Vocabulary", + "binding": function (o) { + return o.VOCABULARY_ID; + } }, { - title: 'Domain', - data: 'DOMAIN_ID' + "caption": "Invalid Reason", + "binding": function (o) { + return o.INVALID_REASON_CAPTION; + } }, { - title: 'Vocabulary', - data: 'VOCABULARY_ID' + "caption": "Class", + "binding": function (o) { + return o.CONCEPT_CLASS_ID; + } }, { - title: 'Ancestor', - data: 'ANCESTORS' - }]; - const relatedSourcecodesOptions = { - Facets: [{ - 'caption': 'Vocabulary', - 'binding': function (o) { - return o.VOCABULARY_ID; - } + "caption": "Domain", + "binding": function (o) { + return o.DOMAIN_ID; + } + }] + }; + + const metatrix = { + "ATC.ATC 4th": { + childRelationships: [{ + name: "Has descendant of", + range: [0, 1] + }], + parentRelationships: [{ + name: "Has ancestor of", + range: [0, 5] + }] + }, + "ICD9CM.5-dig billing code": { + childRelationships: [{ + name: "Subsumes", + range: [0, 1] + }], + parentRelationships: [{ + name: "Is a", + range: [0, 1] + }] + }, + "ICD9CM.4-dig nonbill code": { + childRelationships: [{ + name: "Subsumes", + range: [0, 1] + }], + parentRelationships: [{ + name: "Is a", + range: [0, 1] }, { - 'caption': 'Invalid Reason', - 'binding': function (o) { - return o.INVALID_REASON_CAPTION; - } + name: "Non-standard to Standard map (OMOP)", + range: [0, 1] + }] + }, + "ICD9CM.3-dig nonbill code": { + childRelationships: [{ + name: "Subsumes", + range: [0, 1] + }], + parentRelationships: [{ + name: "Non-standard to Standard map (OMOP)", + range: [0, 999] + }] + }, + "RxNorm.Ingredient": { + childRelationships: [{ + name: "Ingredient of (RxNorm)", + range: [0, 999] + }], + parentRelationships: [{ + name: "Has ancestor of", + vocabulary: ["ATC", "ETC"], + range: [0, 1] + }] + }, + "RxNorm.Brand Name": { + childRelationships: [{ + name: "Ingredient of (RxNorm)", + range: [0, 999] + }], + parentRelationships: [{ + name: "Tradename of (RxNorm)", + range: [0, 999] + }] + }, + "RxNorm.Branded Drug": { + childRelationships: [{ + name: "Consists of (RxNorm)", + range: [0, 999] + }], + parentRelationships: [{ + name: "Has ingredient (RxNorm)", + range: [0, 999] + }, { + name: "RxNorm to ATC (RxNorm)", + range: [0, 999] }, { - 'caption': 'Class', - 'binding': function (o) { - return o.CONCEPT_CLASS_ID; - } + name: "RxNorm to ETC (FDB)", + range: [0, 999] + }] + }, + "RxNorm.Clinical Drug Comp": { + childRelationships: [], + parentRelationships: [{ + name: "Has precise ingredient (RxNorm)", + range: [0, 999] }, { - 'caption': 'Domain', - 'binding': function (o) { - return o.DOMAIN_ID; - } + name: "Has ingredient (RxNorm)", + range: [0, 999] + }] + }, + "CPT4.CPT4": { + childRelationships: [{ + name: "Has descendant of", + range: [0, 1] + }], + parentRelationships: [{ + name: "Has ancestor of", + range: [0, 1] }] - }; + }, + "CPT4.CPT4 Hierarchy": { + childRelationships: [{ + name: "Has descendant of", + range: [0, 1] + }], + parentRelationships: [{ + name: "Has ancestor of", + range: [0, 1] + }] + }, + "ETC.ETC": { + childRelationships: [{ + name: "Has descendant of", + range: [0, 1] + }], + parentRelationships: [{ + name: "Has ancestor of", + range: [0, 1] + }] + }, + "MedDRA.LLT": { + childRelationships: [{ + name: "Has descendant of", + range: [0, 1] + }], + parentRelationships: [{ + name: "Has ancestor of", + range: [0, 1] + }] + }, + "MedDRA.PT": { + childRelationships: [{ + name: "Has descendant of", + range: [0, 1] + }], + parentRelationships: [{ + name: "Has ancestor of", + range: [0, 1] + }] + }, + "MedDRA.HLT": { + childRelationships: [{ + name: "Has descendant of", + range: [0, 1] + }], + parentRelationships: [{ + name: "Has ancestor of", + range: [0, 1] + }] + }, + "MedDRA.SOC": { + childRelationships: [{ + name: "Has descendant of", + range: [0, 1] + }], + parentRelationships: [{ + name: "Has ancestor of", + range: [0, 1] + }] + }, + "MedDRA.HLGT": { + childRelationships: [{ + name: "Has descendant of", + range: [0, 1] + }], + parentRelationships: [{ + name: "Has ancestor of", + range: [0, 1] + }] + }, + "SNOMED.Clinical Finding": { + childRelationships: [{ + name: "Has descendant of", + range: [0, 1] + }], + parentRelationships: [{ + name: "Has ancestor of", + range: [0, 1] + }] + }, + "SNOMED.Procedure": { + childRelationships: [{ + name: "Has descendant of", + range: [0, 1] + }], + parentRelationships: [{ + name: "Has ancestor of", + range: [0, 1] + }] + } + }; - const metatrix = { - 'ATC.ATC 4th': { - childRelationships: [{ - name: 'Has descendant of', - range: [0, 1] - }], - parentRelationships: [{ - name: 'Has ancestor of', - range: [0, 5] - }] - }, - 'ICD9CM.5-dig billing code': { - childRelationships: [{ - name: 'Subsumes', - range: [0, 1] - }], - parentRelationships: [{ - name: 'Is a', - range: [0, 1] - }] - }, - 'ICD9CM.4-dig nonbill code': { - childRelationships: [{ - name: 'Subsumes', - range: [0, 1] - }], - parentRelationships: [{ - name: 'Is a', - range: [0, 1] - }, { - name: 'Non-standard to Standard map (OMOP)', - range: [0, 1] - }] - }, - 'ICD9CM.3-dig nonbill code': { - childRelationships: [{ - name: 'Subsumes', - range: [0, 1] - }], - parentRelationships: [{ - name: 'Non-standard to Standard map (OMOP)', - range: [0, 999] - }] - }, - 'RxNorm.Ingredient': { - childRelationships: [{ - name: 'Ingredient of (RxNorm)', - range: [0, 999] - }], - parentRelationships: [{ - name: 'Has ancestor of', - vocabulary: ['ATC', 'ETC'], - range: [0, 1] - }] - }, - 'RxNorm.Brand Name': { - childRelationships: [{ - name: 'Ingredient of (RxNorm)', - range: [0, 999] - }], - parentRelationships: [{ - name: 'Tradename of (RxNorm)', - range: [0, 999] - }] - }, - 'RxNorm.Branded Drug': { - childRelationships: [{ - name: 'Consists of (RxNorm)', - range: [0, 999] - }], - parentRelationships: [{ - name: 'Has ingredient (RxNorm)', - range: [0, 999] - }, { - name: 'RxNorm to ATC (RxNorm)', - range: [0, 999] - }, { - name: 'RxNorm to ETC (FDB)', - range: [0, 999] - }] - }, - 'RxNorm.Clinical Drug Comp': { - childRelationships: [], - parentRelationships: [{ - name: 'Has precise ingredient (RxNorm)', - range: [0, 999] - }, { - name: 'Has ingredient (RxNorm)', - range: [0, 999] - }] - }, - 'CPT4.CPT4': { - childRelationships: [{ - name: 'Has descendant of', - range: [0, 1] - }], - parentRelationships: [{ - name: 'Has ancestor of', - range: [0, 1] - }] - }, - 'CPT4.CPT4 Hierarchy': { - childRelationships: [{ - name: 'Has descendant of', - range: [0, 1] - }], - parentRelationships: [{ - name: 'Has ancestor of', - range: [0, 1] - }] - }, - 'ETC.ETC': { - childRelationships: [{ - name: 'Has descendant of', - range: [0, 1] - }], - parentRelationships: [{ - name: 'Has ancestor of', - range: [0, 1] - }] - }, - 'MedDRA.LLT': { - childRelationships: [{ - name: 'Has descendant of', - range: [0, 1] - }], - parentRelationships: [{ - name: 'Has ancestor of', - range: [0, 1] - }] - }, - 'MedDRA.PT': { - childRelationships: [{ - name: 'Has descendant of', - range: [0, 1] - }], - parentRelationships: [{ - name: 'Has ancestor of', - range: [0, 1] - }] - }, - 'MedDRA.HLT': { - childRelationships: [{ - name: 'Has descendant of', - range: [0, 1] - }], - parentRelationships: [{ - name: 'Has ancestor of', - range: [0, 1] - }] - }, - 'MedDRA.SOC': { - childRelationships: [{ - name: 'Has descendant of', - range: [0, 1] - }], - parentRelationships: [{ - name: 'Has ancestor of', - range: [0, 1] - }] - }, - 'MedDRA.HLGT': { - childRelationships: [{ - name: 'Has descendant of', - range: [0, 1] - }], - parentRelationships: [{ - name: 'Has ancestor of', - range: [0, 1] - }] - }, - 'SNOMED.Clinical Finding': { - childRelationships: [{ - name: 'Has descendant of', - range: [0, 1] - }], - parentRelationships: [{ - name: 'Has ancestor of', - range: [0, 1] - }] - }, - 'SNOMED.Procedure': { - childRelationships: [{ - name: 'Has descendant of', - range: [0, 1] - }], - parentRelationships: [{ - name: 'Has ancestor of', - range: [0, 1] - }] + const getRelatedSourcecodesColumns = (sharedState, context) => [{ + title: "", + render: (s, p, d) => { + var css = ""; + var icon = "fa-shopping-cart"; + var tag = "i"; + if (sharedState.selectedConceptsIndex[d.CONCEPT_ID] == 1) { + css = " selected"; } - }; - - const getRelatedSourcecodesColumns = (sharedState, context) => [{ - title: '', - render: (s, p, d) => { - var css = ''; - var icon = 'fa-shopping-cart'; - var tag = 'i' - if (sharedState.selectedConceptsIndex[d.CONCEPT_ID] == 1) { - css = ' selected'; - } - if (!context.canEditCurrentConceptSet()) { - css += ' readonly'; - tag = 'span'; - } - return '<' + tag + ' class="fa ' + icon + ' ' + css + '">'; - }, - orderable: false, - searchable: false - }, { - title: 'Id', - data: 'CONCEPT_ID' - }, { - title: 'Code', - data: 'CONCEPT_CODE' - }, { - title: 'Name', - data: 'CONCEPT_NAME', - render: function (s, p, d) { - var valid = d.INVALID_REASON_CAPTION == 'Invalid' ? 'invalid' : ''; - return '' + d.CONCEPT_NAME + ''; + if (!context.canEditCurrentConceptSet()) { + css += " readonly"; + tag = "span"; } - }, { - title: 'Class', - data: 'CONCEPT_CLASS_ID' - }, { - title: 'Standard Concept Caption', - data: 'STANDARD_CONCEPT_CAPTION', - visible: false - }, { - title: 'Domain', - data: 'DOMAIN_ID' - }, { - title: 'Vocabulary', - data: 'VOCABULARY_ID' - }]; + return "<" + tag + " class=\"fa " + icon + " " + css + "\">"; + }, + orderable: false, + searchable: false + }, { + title: "Id", + data: "CONCEPT_ID" + }, { + title: "Code", + data: "CONCEPT_CODE" + }, { + title: "Name", + data: "CONCEPT_NAME", + render: function (s, p, d) { + var valid = d.INVALID_REASON_CAPTION == "Invalid" ? "invalid" : ""; + return "" + d.CONCEPT_NAME + ""; + } + }, { + title: "Class", + data: "CONCEPT_CLASS_ID" + }, { + title: "Standard Concept Caption", + data: "STANDARD_CONCEPT_CAPTION", + visible: false + }, { + title: "Domain", + data: "DOMAIN_ID" + }, { + title: "Vocabulary", + data: "VOCABULARY_ID" + }]; + + const apiPaths = { + role: (id = "") => `${config.api.url}role/${id}`, + roleUsers: roleId => `${config.api.url}role/${roleId}/users`, + permissions: () => `${config.api.url}permission`, + rolePermissions: roleId => `${config.api.url}role/${roleId}/permissions`, + relations: (roleId, relation, ids = []) => `${config.api.url}role/${roleId}/${relation}/${ids.join("+")}`, + jobs: () => `${config.api.url}job/execution?comprehensivePage=true`, + job: (id) => `${config.api.url}job/${id}`, + jobByName: (name, type) => `${config.api.url}job/type/${type}/name/${name}`, + }; - const apiPaths = { - role: (id = '') => `${config.api.url}role/${id}`, - roleUsers: roleId => `${config.api.url}role/${roleId}/users`, - permissions: () => `${config.api.url}permission`, - rolePermissions: roleId => `${config.api.url}role/${roleId}/permissions`, - relations: (roleId, relation, ids = []) => `${config.api.url}role/${roleId}/${relation}/${ids.join('+')}`, - jobs: () => `${config.api.url}job/execution?comprehensivePage=true`, - job: (id) => `${config.api.url}job/${id}`, - jobByName: (name, type) => `${config.api.url}job/type/${type}/name/${name}`, - }; + const applicationStatuses = { + initializing: "initializing", + running: "running", + noSourcesAvailable: "no-sources-available", + failed: "failed", + }; - const applicationStatuses = { - initializing: 'initializing', - running: 'running', - noSourcesAvailable: 'no-sources-available', - failed: 'failed', - }; - - return { - minChartHeight, - treemapGradient, - defaultDeciles, - relatedConceptsOptions, - getRelatedConceptsColumns, - relatedSourcecodesOptions, - metatrix, - getRelatedSourcecodesColumns, - apiPaths, - applicationStatuses, - }; - } -); \ No newline at end of file + return { + minChartHeight, + treemapGradient, + defaultDeciles, + relatedConceptsOptions, + getRelatedConceptsColumns, + relatedSourcecodesOptions, + metatrix, + getRelatedSourcecodesColumns, + apiPaths, + applicationStatuses, + }; +} +); diff --git a/js/settings.js b/js/settings.js index 89c06f3ce..5a3259db8 100644 --- a/js/settings.js +++ b/js/settings.js @@ -1,5 +1,5 @@ const settingsObject = { - baseUrl: 'js', + baseUrl: "js", config: { text: { useXhr: function (url, protocol, hostname, port) { @@ -8,65 +8,65 @@ const settingsObject = { }, }, packages: [{ - name: "databindings", - location: "extensions/bindings" - }, - { - name: "cohortdefinitionviewer", - location: "components/cohortdefinitionviewer" - }, - { - name: "circe", - location: "components/circe" - }, - { - name: "cyclops", - location: "components/cyclops" - }, - { - name: "evidence", - location: "components/evidence" - }, - { - name: "extenders", - location: "extenders" - }, - { - name: "featureextraction", - location: "components/featureextraction" - }, - { - name: "pages", - location: "pages", - }, - { - name: "lodash", - location: "../node_modules/lodash", - main: "lodash", - }, - { - name: "urijs", - location: "../node_modules/urijs/src", - main: "URI" - }, - { - name: "facets", - location: "../node_modules/facets", - main: "facets" - }, - { - name: "bootstrap-datetimepicker.css", - location: "../node_modules/bootstrap-datetimepicker/src/less", - main: "less!bootstrap-datetimepicker.less", - }, + name: "databindings", + location: "extensions/bindings" + }, + { + name: "cohortdefinitionviewer", + location: "components/cohortdefinitionviewer" + }, + { + name: "circe", + location: "components/circe" + }, + { + name: "cyclops", + location: "components/cyclops" + }, + { + name: "evidence", + location: "components/evidence" + }, + { + name: "extenders", + location: "extenders" + }, + { + name: "featureextraction", + location: "components/featureextraction" + }, + { + name: "pages", + location: "pages", + }, + { + name: "lodash", + location: "../node_modules/lodash", + main: "lodash", + }, + { + name: "urijs", + location: "../node_modules/urijs/src", + main: "URI" + }, + { + name: "facets", + location: "../node_modules/facets", + main: "facets" + }, + { + name: "bootstrap-datetimepicker.css", + location: "../node_modules/bootstrap-datetimepicker/src/less", + main: "less!bootstrap-datetimepicker.less", + }, ], shim: { "colorbrewer": { - exports: 'colorbrewer' + exports: "colorbrewer" }, "bootstrap": { "deps": [ - 'jquery' + "jquery" ] }, "prism": { @@ -80,13 +80,13 @@ const settingsObject = { }, map: { "*": { - 'jqueryui/jquery.ddslick': 'assets/jqueryui/jquery.ddslick', - 'jqueryui/autoGrowInput': 'assets/jqueryui/autoGrowInput', - 'd3-color': 'd3', - 'd3-interpolate': 'd3', - 'd3-selection': 'd3', - 'd3-collection': 'd3', - 'services/VocabularyProvider': 'services/Vocabulary' + "jqueryui/jquery.ddslick": "assets/jqueryui/jquery.ddslick", + "jqueryui/autoGrowInput": "assets/jqueryui/autoGrowInput", + "d3-color": "d3", + "d3-interpolate": "d3", + "d3-selection": "d3", + "d3-collection": "d3", + "services/VocabularyProvider": "services/Vocabulary" } }, paths: { @@ -177,8 +177,8 @@ const settingsObject = { }, }; -if (typeof define !== 'undefined') { +if (typeof define !== "undefined") { define(() => settingsObject); } else { module.exports = settingsObject; -} \ No newline at end of file +} diff --git a/package.json b/package.json index 5b70cdadd..1d91a4948 100644 --- a/package.json +++ b/package.json @@ -35,6 +35,8 @@ "@babel/plugin-proposal-object-rest-spread": "^7.0.0", "@babel/polyfill": "^7.0.0", "@babel/preset-env": "^7.1.5", + "babel-eslint": "^10.0.1", + "eslint": "^5.12.0", "esprima": "^4.0.1", "html-document": "^0.8.1", "requirejs": "^2.3.4", @@ -57,6 +59,7 @@ "datatables.net": "^1.10.15", "datatables.net-buttons": "^1.5.4", "director": "^1.2.8", + "eslint-plugin-requirejs": "^3.2.0", "facets": "^0.1.1", "file-saver": "^1.3.8", "jquery": "^1.11.2",