Skip to content

Commit

Permalink
🔥 removing redundant code.
Browse files Browse the repository at this point in the history
  • Loading branch information
ayush2k committed Aug 5, 2016
1 parent 82934e9 commit 81c736b
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 81c736b

Please sign in to comment.