Skip to content

Commit

Permalink
Updates linter and cleans up
Browse files Browse the repository at this point in the history
  • Loading branch information
abea committed Mar 30, 2020
1 parent 58c7108 commit 55e6dfc
Show file tree
Hide file tree
Showing 9 changed files with 50 additions and 41 deletions.
2 changes: 1 addition & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"extends": "punkave"
"extends": "apostrophe"
}
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# Changelog
/Users/abea/Apos/apostrophe-palette/lib/modules/apostrophe-palette-widgets/public/js/leanUser.js
## 2.0.24

* Updates the eslint config and cleans up linter errors. Sets up CircleCI.

## 2.0.23

Expand Down
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ module.exports = {
],
directory: 'lib/modules'
}
};
};
22 changes: 10 additions & 12 deletions lib/modules/apostrophe-palette-global/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
var util = require('util')
var _ = require('lodash');
var async = require('async');

module.exports = {
improve: 'apostrophe-global',
Expand All @@ -14,14 +12,14 @@ module.exports = {
if (options.arrangePaletteFields) {

options.arrangePaletteFields.forEach(function(item) {

var temp;
if (_.isString(item)) {

// top level, individual field
var field = _.find(options.paletteFields, { name: item });

if (field) {
var temp = {
temp = {
name: field.name,
label: field.label,
type: 'field',
Expand All @@ -30,24 +28,24 @@ module.exports = {

arrangedPaletteFields.push(temp);
} else {
self.apos.utils.warn('Unrecognized vield in arrangePaletteFields: ' + item);
self.apos.utils.warn('Unrecognized field in arrangePaletteFields: ' + item);
}
} else if (item.fields && _.isString(item.fields[0])) {

// group of fields
var temp = {
temp = {
name: item.name,
label: item.label,
type: 'group',
schema: []
};

item.fields.forEach( function(field) {
item.fields.forEach(function(field) {
var pField = _.find(options.paletteFields, { name: field });
if (pField) {
temp.schema.push(pField);
} else {
console.log('Unrecognized field in arrangePaletteFields: ' + field);
self.apos.utils.warn('Unrecognized field in arrangePaletteFields: ' + field);
}
});

Expand All @@ -56,7 +54,7 @@ module.exports = {
} else if (item.fields && _.isObject(item.fields[0])) {

// group of groups
var temp = {
temp = {
name: item.name,
label: item.label,
type: 'group',
Expand All @@ -69,7 +67,7 @@ module.exports = {
label: group.label,
type: 'group',
schema: []
}
};

group.fields.forEach(function (field) {
var pField = _.find(options.paletteFields, { name: field });
Expand Down Expand Up @@ -113,7 +111,7 @@ module.exports = {

// Separate the palette field names so we can group them in a tab
var fieldNames = _.map(options.paletteFields, function (field) {
return field.name
return field.name;
});

options.arrangeFields = (options.arrangeFields || []).concat([
Expand Down Expand Up @@ -157,7 +155,7 @@ module.exports = {
}
if (field.valueTemplate) {
var regex = /%VALUE%/gi;
rule += selector + '{ ' + property + ': ' + field.valueTemplate.replace(regex, fieldValue + fieldUnit) + '; }'
rule += selector + '{ ' + property + ': ' + field.valueTemplate.replace(regex, fieldValue + fieldUnit) + '; }';
} else {
rule += selector + ' { ' + property + ': ' + fieldValue + fieldUnit + '; }';
}
Expand Down
2 changes: 1 addition & 1 deletion lib/modules/apostrophe-palette-global/public/js/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ apos.define('apostrophe-global', {
}
});
}
});
});
2 changes: 1 addition & 1 deletion lib/modules/apostrophe-palette-schemas/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module.exports = {
improve: 'apostrophe-schemas'
};
};
8 changes: 4 additions & 4 deletions lib/modules/apostrophe-palette-widgets/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,20 +51,20 @@ module.exports = {
output.workflowModified = true;

return self.apos.docs.db.update({
_id: req.data.global._id
_id: req.data.global._id
}, {
$set: output,
$inc: {
paletteCounter: 1
},
}
}, callback);
};
};

self.route('post', 'palette-update', function (req, res) {
return self.updatePalette(req, function (err) {
if (err) {
console.error(err);
self.apos.utils.error(err);
}
return res.send({ status: err ? 'error' : 'ok' });
});
Expand All @@ -77,7 +77,7 @@ module.exports = {
var browserOptions = superGetCreateSingletonOptions(req);
var globalModule = self.apos.docs.getManager('apostrophe-global').find(req, {}).options.module;

browserOptions.schema = globalModule.schema
browserOptions.schema = globalModule.schema;
browserOptions.piece = req.data.global;

return browserOptions;
Expand Down
30 changes: 18 additions & 12 deletions lib/modules/apostrophe-palette-widgets/public/js/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,14 @@ apos.define('apostrophe-palette-widgets', {
extend: 'apostrophe-widgets',

construct: function (self, options) {

// Overridable hooks for project level
self.beforeSubmit = function ($field, fieldValue, fieldSchema) {},
self.afterSubmit = function ($field, fieldValue, fieldSchema) {},
self.beforeSubmit = function ($field, fieldValue, fieldSchema) {};
self.afterSubmit = function ($field, fieldValue, fieldSchema) {};

self.play = function ($widget, data, options) {

var $form = $('[data-apos-palette-form]');
var $tag = $('[data-apos-palette-styles]')
var $tag = $('[data-apos-palette-styles]');
var schema = self.options.schema;
var piece = _.cloneDeep(self.options.piece);

Expand All @@ -35,14 +34,16 @@ apos.define('apostrophe-palette-widgets', {
});

$this.parent().addClass(activeClass);

})
});
};

self.init = function ($form, $tag, schema, piece) {
return apos.schemas.populate($form, schema, piece, function (err) {
if (err) {
apos.notify('A problem populating/enhancing the palette field', { type: 'error', dismiss: true });
apos.notify('A problem populating/enhancing the palette field', {
type: 'error',
dismiss: true
});
return;
}

Expand Down Expand Up @@ -77,7 +78,10 @@ apos.define('apostrophe-palette-widgets', {
self.apply($field, fieldValue, fieldSchema, $tag);
var save = self.debouncedSaves[fieldSchema.name];
if (!save) {
save = _.debounce(self.save, 250, { leading: true, trailing: true });
save = _.debounce(self.save, 250, {
leading: true,
trailing: true
});
self.debouncedSaves[fieldSchema.name] = save;
}
save($field, fieldValue, fieldSchema, $tag);
Expand All @@ -90,7 +94,7 @@ apos.define('apostrophe-palette-widgets', {
var mediaQuery = $field.attr('data-apos-palette-media-query');
var unit = $field.attr('data-apos-palette-unit') || "";
var valueTemplate = $field.attr('data-apos-value-template') || false;
var value = $field.find(':input:not([data-apos-workflow-field-state-control])').val()
var value = $field.find(':input:not([data-apos-workflow-field-state-control])').val();

if (!value) {
return;
Expand All @@ -106,7 +110,7 @@ apos.define('apostrophe-palette-widgets', {

if (valueTemplate) {
var regex = /%VALUE%/gi;
rule = rule + selector + " { " + prop + ": " + valueTemplate.replace(regex, value + unit) + "; } ";
rule = rule + selector + " { " + prop + ": " + valueTemplate.replace(regex, value + unit) + "; } ";
} else {
rule = rule + selector + " { " + prop + ": " + value + unit + "; } ";
}
Expand All @@ -130,7 +134,10 @@ apos.define('apostrophe-palette-widgets', {

return send(function(err) {
if (err) {
apos.notify('Something was not right. Please review your submission.', { type: 'error', dismiss: true });
apos.notify('Something was not right. Please review your submission.', {
type: 'error',
dismiss: true
});
} else {
self.afterSubmit($field, fieldValue, fieldSchema, $tag);
}
Expand All @@ -152,6 +159,5 @@ apos.define('apostrophe-palette-widgets', {
};
};


}
});
19 changes: 10 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"name": "apostrophe-palette",
"version": "2.0.23",
"version": "2.0.24",
"description": "In-context style toggling save to the apostrophe-global doc",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"test": "npx eslint ."
},
"repository": {
"type": "git",
Expand All @@ -14,19 +14,20 @@
"ApostropheCMS",
"apostrophe"
],
"author": "P'unk Ave",
"author": "Apostrophe Technologies, Inc.",
"license": "MIT",
"bugs": {
"url": "https://github.com/apostrophecms/apostrophe-palette/issues"
},
"homepage": "https://github.com/apostrophecms/apostrophe-palette#readme",
"devDependencies": {
"eslint": ">=4.18.2",
"eslint-config-punkave": "^1.0.8",
"eslint-config-standard": "^10.2.1",
"eslint-plugin-import": "^2.7.0",
"eslint-plugin-node": "^5.1.0",
"eslint-plugin-standard": "^3.0.1"
"eslint": "^6.8.0",
"eslint-config-apostrophe": "^3.1.0",
"eslint-config-standard": "^14.1.0",
"eslint-plugin-import": "^2.20.1",
"eslint-plugin-node": "^11.0.0",
"eslint-plugin-promise": "^4.2.1",
"eslint-plugin-standard": "^4.0.1"
},
"dependencies": {
"async": "^2.6.0",
Expand Down

0 comments on commit 55e6dfc

Please sign in to comment.