diff --git a/css/base.css b/css/base.css index 44ab2914..1abaf048 100644 --- a/css/base.css +++ b/css/base.css @@ -744,6 +744,7 @@ table.permission-editor td.checkbox { .panel-form { display: flex; flex-direction: column; + padding: 0; } .panel-form-row { @@ -1574,12 +1575,10 @@ ul.tabbar li.active > a:after { border-bottom: 1px solid #ccc; box-shadow: 0 1px 0 rgba(0, 0, 0, 0.1); transition: all 0.1s ease-in-out; - width: 100%; max-height: 10rem; min-height: 4rem; overflow-y: scroll; - margin: 0.25rem 0rem 0.25rem 0rem; - padding: 0 0 0.5rem 0.5rem; + margin: 0.25rem 0 0.25rem 0; outline: none; color: #666; align-items: center; diff --git a/index.html b/index.html index 7f53e0a0..01cb92bd 100644 --- a/index.html +++ b/index.html @@ -1449,14 +1449,6 @@ this.props.onSubmit(null, vcard(this.state.fullName, img)); }, - handleShowTagManager: function() { - this.setState({showTagManager: true}); - }, - - handleHideTagManager: function() { - this.setState({showTagManager: false}); - }, - handleTagsUpdated: function(tags) { this.setState({showTagManager: false}); // Check if tags have actually changed. @@ -1466,6 +1458,10 @@ this.props.onUpdateTags(tags); }, + handleHideTagManager: function() { + // do nothing. Needed to enable Cancel button in tag manager. + }, + render: function() { var tags = []; this.state.tags.map(function(tag) { @@ -1515,20 +1511,12 @@
- {this.state.showTagManager ? - - : -
-
- - edit Manage tags - - {tags} -
- } +
); } @@ -1539,26 +1527,15 @@ var TagManager = React.createClass({ getInitialState: function() { return { - tags: this.wrapTags(this.props.tags), + tags: this.props.tags, tagInput: '', + activated: this.props.activated, noTagsMessage: 'Add some tags' }; }, - wrapTags: function(tags) { - var wrapped = []; - tags.map(function(tag) { - wrapped.push({user: tag}); - }); - return wrapped; - }, - - unwrapTags: function(tags) { - var unwrapped = []; - tags.map(function(tag) { - unwrapped.push(tag.user); - }); - return unwrapped; + handleShowTagManager: function() { + this.setState({activated: true}); }, handleTagInput: function(text) { @@ -1579,47 +1556,81 @@ tag = tag.trim(); if (tag.length > 0) { var tags = this.state.tags.slice(0); - tags.push({user: tag}); + tags.push(tag); this.setState({tags: tags, tagInput: ''}); } + if (this.props.onTagsChanged) { + this.props.onTagsChanged(tags); + } }, handleRemoveTag: function(tag, index) { var tags = this.state.tags.slice(0); tags.splice(index, 1); this.setState({tags: tags}); + if (this.props.onTagsChanged) { + this.props.onTagsChanged(tags); + } }, handleSubmit: function() { - var tags = this.unwrapTags(this.state.tags); + var tags = this.state.tags.slice(0); var inp = this.state.tagInput.trim(); if (inp.length > 0) { tags.push(inp); } this.props.onSubmit(tags); + this.setState({activated: false, tags: tags}); }, handleCancel: function() { + this.setState({activated: false, tags: this.props.tags}); this.props.onCancel(); }, render: function() { + var tags = []; + if (this.state.activated) { + this.state.tags.map(function(tag) { + tags.push({user: tag}); + }); + } else { + this.state.tags.map(function(tag) { + tags.push({tag}); + }); + if (tags.length == 0) { + tags = No tags defined. Add some.; + } + } return ( -
+
- -
- -
- - +
+ {this.state.activated ? +
+ + {this.props.onSubmit || this.props.onCancel ? +
+ + +
+ : null} +
+ : +
+ + edit Manage tags + + {tags} +
+ }
); } @@ -2020,12 +2031,14 @@
- + +
@@ -2123,7 +2136,8 @@ return { fn: '', // full/formatted name private: '', - imageDataUrl: null + imageDataUrl: null, + tags: [] }; }, handleFnChange: function(e) { @@ -2135,6 +2149,9 @@ handleImageChanged: function(img) { this.setState({imageDataUrl: img}); }, + handleTagsUpdated: function(tags) { + this.setState({tags: tags}); + }, handleSubmit: function(e) { e.preventDefault(); if (this.state.fn && this.state.fn.trim()) { @@ -2148,7 +2165,7 @@ submitClasses += " disabled"; } return ( -
+
@@ -2163,10 +2180,14 @@ onError={this.props.onError} onImageChanged={this.handleImageChanged} />
+
- +
-
+
); } });