Skip to content
This repository has been archived by the owner on Nov 21, 2020. It is now read-only.

Added field name automatic slugification. #6

Merged
merged 9 commits into from
Jan 27, 2016
Merged

Conversation

n1k0
Copy link
Contributor

@n1k0 n1k0 commented Jan 15, 2016

This patch adds support for automatic field name generation when a new title is entered for the first time. It also adds unit and functional tests for the form reducer and the EditableField component.

r=? @almet

.toLowerCase()
.trim()
.replace(/\s/g, "_")
.replace(/[^a-z0-9]/, "");

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -24,6 +25,10 @@ function clone(obj) {
return JSON.parse(JSON.stringify(obj));
}

function unique(array) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we rename this to deduplicateArray?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Huh. I thought unique was meaningful enough :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unique is not a verb, that's why I was mistaken.

@almet
Copy link
Member

almet commented Jan 27, 2016

If I'm not mistaken, the user sees the name of the field and its id, and can update both of them.

What about having only the name exposed, and having the id hidden from the user? I believe it's not something the users need to know.

What do you think?

Otherwise, the code changes looks good to me.

@n1k0
Copy link
Contributor Author

n1k0 commented Jan 27, 2016

What about having only the name exposed, and having the id hidden from the user? I believe it's not something the users need to know.

Well if you plan on building the right JSON schema for third-party tools requiring proper field naming? That's really important imho (think kinto-admin or any tool wanting to retrieve the json schema definition).

I understand that for totally non-technical users just wanting a shareable UI it might be unwanted/get in the way, but I think we shouldn't drive the implementation by their sole needs...

Maybe we could iterate on this, for example by allowing a configureable option to hide the name field (which is what you call the id); though that should probably be covered by a new issue.

@almet
Copy link
Member

almet commented Jan 27, 2016

that works for me :)

@n1k0
Copy link
Contributor Author

n1k0 commented Jan 27, 2016

I'm landing this. Filed #8 for hiding the name field.

n1k0 added a commit that referenced this pull request Jan 27, 2016
Added field name automatic slugification.
@n1k0 n1k0 merged commit 8ceae75 into master Jan 27, 2016
@n1k0 n1k0 deleted the field-name-slugifier branch January 27, 2016 20:55
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants