apostrophe-schemas
Advanced tools
Comparing version 0.5.69 to 0.5.70
@@ -322,2 +322,8 @@ /* jshint node:true */ | ||
return self._apos._aposLocals.aposSingletonIsEmpty({ area: value, type: field.widgetType }); | ||
}, | ||
select: function(field, value) { | ||
// A select element is considered empty if it doesn't | ||
// contain one of its allowed choices, which can happen | ||
// in various import situations | ||
return (!_.contains(_.pluck(field.choices, 'value'), value)); | ||
} | ||
@@ -324,0 +330,0 @@ }; |
{ | ||
"version": "0.5.69", | ||
"version": "0.5.70", | ||
"name": "apostrophe-schemas", | ||
@@ -4,0 +4,0 @@ "description": "Schemas for easy editing of properties in Apostrophe objects", |
@@ -26,3 +26,3 @@ /* globals: async, apos, _, aposPages, async, $ */ | ||
if(field.required === true) { | ||
self.addError($el, field.name, true); | ||
self.addError($el, field.name, true, true); | ||
} | ||
@@ -50,5 +50,3 @@ return apos.afterYield(callback); | ||
var $fieldset = self.findFieldset($el, field); | ||
var $helpText = $fieldset.next('p.apos-help'); | ||
$fieldset.addClass('apos-hidden'); | ||
$helpText.addClass('apos-hidden'); | ||
}); | ||
@@ -65,5 +63,3 @@ } | ||
var $fieldset = self.findFieldset($el, field); | ||
var $helpText = $fieldset.next('p.apos-help'); | ||
$fieldset.removeClass('apos-hidden'); | ||
$helpText.removeClass('apos-hidden'); | ||
}); | ||
@@ -98,3 +94,3 @@ } | ||
self.convertFields = function($el, schema, data, callback) { | ||
self.findSafe($el, '[data-name]').removeClass('apos-error').find('.apos-error-message').remove(); | ||
self.findSafe($el, '[data-name]').removeClass('apos-error').removeClass('apos-error-required').removeClass('apos-error-in-advance').find('.apos-error-message').remove(); | ||
var failing; | ||
@@ -200,4 +196,2 @@ | ||
$editView.append(data); | ||
// Make sure slideshows, videos, etc. get their JS | ||
apos.enablePlayers($editView); | ||
return callback(null); | ||
@@ -376,5 +370,3 @@ }); | ||
data[name] = values; | ||
// For this type 'required' means you must check | ||
// at least one of the boxes | ||
if (field.required && (!data[name].length)) { | ||
if (field.required && !data[name]) { | ||
return apos.afterYield(_.partial(callback, 'required')); | ||
@@ -457,12 +449,5 @@ } | ||
addMoveHandler($element); | ||
addOpenHandler($element); | ||
$element.attr('data-id', data[i].id); | ||
if (apos.data.schemaWidgetsUi && !apos.data.schemaWidgetsUi.toggleUi){ | ||
self.findSafe($element, '[data-open-item]').hide(); | ||
} else { | ||
$element.addClass('apos-array-toggle'); | ||
} | ||
$elements.append($element); | ||
@@ -480,3 +465,2 @@ return self.populateFields($element, field.schema, data[i], function() { | ||
$elements.prepend($element); | ||
addOpenHandler($element); | ||
addRemoveHandler($element); | ||
@@ -507,26 +491,2 @@ addMoveHandler($element); | ||
function addOpenHandler($element){ | ||
var $open = self.findSafe($element, '[data-open-item]'); | ||
var $icon = self.findSafe($open, 'i'); | ||
var $firstInput = self.findSafe($element, 'fieldset:first input'); | ||
$open.on('click', function(){ | ||
toggleItem($element); | ||
return false; | ||
}) | ||
$firstInput.on('click', function(){ | ||
openItem($element); | ||
return false; | ||
}) | ||
function openItem($element){ | ||
$element.toggleClass('apos-array-item--open', true); | ||
$icon.toggleClass('icon-plus', false); | ||
$icon.toggleClass('icon-minus', true); | ||
} | ||
function toggleItem($element){ | ||
$element.toggleClass('apos-array-item--open'); | ||
$icon.toggleClass('icon-plus'); | ||
$icon.toggleClass('icon-minus'); | ||
} | ||
} | ||
function addMoveHandler($element) { | ||
@@ -719,8 +679,12 @@ var $move = self.findSafe($element, '[data-move-item]'); | ||
self.addError = function($el, name, required) { | ||
var $field = self.findSafe($el, '[data-name="' + name + '"]'); | ||
$field.addClass('apos-error'); | ||
self.addError = function($el, name, required, inAdvance) { | ||
var $fieldset = self.findFieldset($el, name); | ||
$fieldset.addClass('apos-error'); | ||
if (required === true) { | ||
self.findSafe($field, 'label').append('<span class="apos-error-message"> * required</span>'); | ||
$fieldset.addClass('apos-error-required'); | ||
self.findSafe($el, '[data-name="' + name + '"]').find('label').append('<span class="apos-error-message"> * required</span>'); | ||
} | ||
if (inAdvance) { | ||
$fieldset.addClass('apos-error-in-advance'); | ||
} | ||
}; | ||
@@ -727,0 +691,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
114295
1583