Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added validation for duplicate labels #763

Open
wants to merge 2 commits into
base: master
from

Conversation

3 participants
@AlvinValdez
Copy link

commented Apr 13, 2019

Fixes issue #717

Before:
If you save an entry after adding two custom fields with the same label (like "URL") only the last one will be saved. No warning is displayed.

Now:
Warning is now displayed before you save entry.

AlvinValdez and others added some commits Apr 13, 2019

@@ -57,6 +57,18 @@ export function validateEntry(entry) {
if (fields.filter(field => !field.property).length > 0) {
errorMessages.push(i18n.t('entry.custom-fields-label-empty-info'));
}

if (fields.length > 3) {
var titleofFields = [];

This comment has been minimized.

Copy link
@perry-mitchell

perry-mitchell Apr 22, 2019

Member

Please use const/let instead to prevent hoisting.

@perry-mitchell perry-mitchell requested a review from sallar Apr 22, 2019

@@ -57,6 +57,18 @@ export function validateEntry(entry) {
if (fields.filter(field => !field.property).length > 0) {
errorMessages.push(i18n.t('entry.custom-fields-label-empty-info'));
}

if (fields.length > 3) {

This comment has been minimized.

Copy link
@sallar

sallar Apr 22, 2019

Member

number of "default fields" are not always 3.
You can find the custom fields like so:

const removeableFields = fields.filter(field => field.removeable);
if (removeableFields.length > 0) {
if (fields.length > 3) {
var titleofFields = [];

for (var i = 3; i < fields.length; i++) {

This comment has been minimized.

Copy link
@sallar

sallar Apr 22, 2019

Member

instead of this you can do:

for (let field of removeableFields) {

@sallar sallar added this to the next-release milestone Apr 22, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.