Skip to content

Commit

Permalink
Merge pull request #80 from ayush2k/structure/redundant-code
Browse files Browse the repository at this point in the history
removing redundant code.
Thank you @ayush2k
  • Loading branch information
scottnath authored Aug 5, 2016
2 parents 82934e9 + 81c736b commit 79ea5ba
Showing 1 changed file with 3 additions and 28 deletions.
31 changes: 3 additions & 28 deletions lib/content-types/merge.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,34 +111,6 @@ const squish = (types) => {
if (attribute.required) {
plugin.required = requiredLevel(attribute.required);
}
if (attribute.repeatable) {
plugin.repeatable = attribute.repeatable;
}

// Organizes repeatable attributes
if (attribute.repeatable) {
if (typeof attribute.repeatable === 'object') {
plugin.repeatable = {};
if (!attribute.repeatable.hasOwnProperty('min')) {
plugin.repeatable.min = 1;
}
else {
plugin.repeatable.min = attribute.repeatable.min;
}
if (!attribute.repeatable.hasOwnProperty('max')) {
plugin.repeatable.max = Number.MAX_SAFE_INTEGER;
}
else {
plugin.repeatable.max = attribute.repeatable.max;
}
}
else if (attribute.repeatable === true) {
plugin.repeatable = {
min: 1,
max: Number.MAX_SAFE_INTEGER,
};
}
}

plugin.id = attribute.id;
plugin.type = attribute.type;
Expand Down Expand Up @@ -191,6 +163,7 @@ const squish = (types) => {

// Sets inputs to min for repeatables
if (attribute.repeatable) {
// Unifies the structure of repeatable
if (typeof attribute.repeatable === 'object') {
plugin.repeatable = {};
if (!attribute.repeatable.hasOwnProperty('min')) {
Expand All @@ -212,6 +185,8 @@ const squish = (types) => {
max: Number.MAX_SAFE_INTEGER,
};
}

// create instances equal to the value of min
const pluginInputs = [];
for (let i = 0; i < plugin.repeatable.min; i++) {
const inputs = _.cloneDeep(plugin.inputs);
Expand Down

0 comments on commit 79ea5ba

Please sign in to comment.