New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

apostrophe-schemas

Package Overview
Dependencies
Maintainers
10
Versions
108
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

apostrophe-schemas - npm Package Compare versions

Comparing version 0.5.40 to 0.5.41

17

index.js

@@ -196,2 +196,19 @@ var async = require('async');

_.each(schema, function(field) {
if (field.type === 'select') {
_.each(field.choices, function(choice){
if (choice.showFields) {
if (!_.isArray(choice.showFields)) {
throw new Error('The \'showFields\' property in the choices of a select field needs to be an array.');
}
_.each(choice.showFields, function(showFieldName){
if (!_.find(schema, function(schemaField){ return schemaField.name == showFieldName; })) {
console.error('WARNING: The field \'' + showFieldName + '\' does not exist in your schema, but you tried to toggle it\'s display with a select field using showFields. STAAAHHHHPP!');
}
});
}
});
}
});
return schema;

@@ -198,0 +215,0 @@ };

2

package.json
{
"version": "0.5.40",
"version": "0.5.41",
"name": "apostrophe-schemas",

@@ -4,0 +4,0 @@ "description": "Schemas for easy editing of properties in Apostrophe objects",

@@ -11,3 +11,4 @@ function AposSchemas() {

if (i >= schema.length) {
return callback(null);
return afterPopulateFields(callback);
// return callback(null);
}

@@ -41,2 +42,56 @@ var field = schema[i];

}
function afterPopulateFields(callback) {
// This function actually toggles the things based on data-show-fields of options in select
function toggleHiddenFields($select){
var $hideFieldOptions = $select.find('option:not(:selected)');
_.each($hideFieldOptions, function(hideFieldOption){
var hideFields = $(hideFieldOption).data('show-fields');
if (hideFields && hideFields.length > 0) {
hideFields = hideFields.split(',');
_.each(hideFields, function(field){
var $fieldset = self.findFieldset($el, field);
$fieldset.addClass('apos-hidden');
});
}
});
var showFields = $select.find('option:selected').data('show-fields');
if (showFields && showFields.length > 0) {
showFields = showFields.split(',');
_.each(showFields, function(field){
var $fieldset = self.findFieldset($el, field);
$fieldset.removeClass('apos-hidden');
});
}
}
// loop over any (safe) select we've marked for functionality, do initial toggle, add listener
_.each(schema, function(field) {
if (field.type == 'select') {
var $fieldset = self.findFieldset($el, field.name);
if ($fieldset.hasClass('apos-fieldset-select-show-fields')){
var $toggleSelect = self.findSafe($fieldset, 'select');
toggleHiddenFields($toggleSelect);
$toggleSelect.on('change', function(){
toggleHiddenFields($(this));
});
}
}
})
callback(null);
}
return populateField(0);

@@ -43,0 +98,0 @@ };

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc