More linting stuff -_- wish I could get this to run locally.
parent
c08dfb1e0c
commit
a34d5c1bfe
|
@ -44,11 +44,11 @@ class Api::V1::Lists::TagsController < Api::BaseController
|
|||
end
|
||||
|
||||
def list_tags
|
||||
names = tag_ids.reject { |t| t =~ /\A[0-9]+\Z/ }
|
||||
ids = tag_ids.select { |t| t =~ /\A[0-9]+\Z/ }
|
||||
names = tag_ids.grep_v(/\A[0-9]+\Z/)
|
||||
ids = tag_ids.grep(/\A[0-9]+\Z/)
|
||||
existing_by_name = Tag.where(name: names.map { |n| Tag.normalize(n) }).select(:id, :name)
|
||||
ids.push(*existing_by_name.map { |t| t.id })
|
||||
not_existing_by_name = names.reject { |n| existing_by_name.any? { |e| e.name == Tag.normalize(n) }}
|
||||
ids.push(*existing_by_name.map(&:id))
|
||||
not_existing_by_name = names.reject { |n| existing_by_name.any? { |e| e.name == Tag.normalize(n) } }
|
||||
created = Tag.find_or_create_by_names(not_existing_by_name)
|
||||
ids.push(*created.map(&:id))
|
||||
Tag.find(ids)
|
||||
|
|
|
@ -37,7 +37,8 @@ const mapDispatchToProps = dispatch => ({
|
|||
class ListEditor extends ImmutablePureComponent {
|
||||
state = {
|
||||
currentTab: 'accounts',
|
||||
}
|
||||
};
|
||||
|
||||
static propTypes = {
|
||||
listId: PropTypes.string.isRequired,
|
||||
onClose: PropTypes.func.isRequired,
|
||||
|
@ -60,6 +61,20 @@ class ListEditor extends ImmutablePureComponent {
|
|||
onReset();
|
||||
}
|
||||
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.switchToAccounts = this.switchToAccounts.bind(this);
|
||||
this.switchToTags = this.switchToTags.bind(this);
|
||||
}
|
||||
|
||||
switchToAccounts() {
|
||||
this.setState({ currentTab: 'accounts' });
|
||||
}
|
||||
|
||||
switchToTags() {
|
||||
this.setState({ currentTab: 'tags' });
|
||||
}
|
||||
|
||||
render() {
|
||||
const { accountIds, tags, searchAccountIds, onClear, intl } = this.props;
|
||||
const showSearch = searchAccountIds.size > 0;
|
||||
|
@ -67,8 +82,8 @@ class ListEditor extends ImmutablePureComponent {
|
|||
<div className='modal-root__modal list-editor'>{this.state.currentTab}
|
||||
<EditListForm />
|
||||
<div className='tab__container'>
|
||||
<button onClick={() => this.setState({ currentTab: 'accounts' })} className={'tab ' + ('accounts' === this.state.currentTab ? 'tab__active' : '')}>{intl.formatMessage(messages.account_tab)} ({accountIds.size})</button>
|
||||
<button onClick={() => this.setState({ currentTab: 'tags' })} className={'tab ' + ('tags' === this.state.currentTab ? 'tab__active' : '')}>{intl.formatMessage(messages.tag_tab)} ({tags.size})</button>
|
||||
<button onClick={this.switchToAccounts} className={'tab ' + ('accounts' === this.state.currentTab ? 'tab__active' : '')}>{intl.formatMessage(messages.account_tab)} ({accountIds.size})</button>
|
||||
<button onClick={this.switchToTags} className={'tab ' + ('tags' === this.state.currentTab ? 'tab__active' : '')}>{intl.formatMessage(messages.tag_tab)} ({tags.size})</button>
|
||||
</div>
|
||||
<div id='list_editor_accounts' className={'accounts' === this.state.currentTab ? 'tab__active' : 'tab__inactive'}>
|
||||
<Search />
|
||||
|
|
|
@ -7791,6 +7791,8 @@ noscript {
|
|||
padding: 5px;
|
||||
background: $ui-base-color;
|
||||
text-align: center;
|
||||
border: 0;
|
||||
color: $primary-text-color;
|
||||
}
|
||||
|
||||
.tab.tab__active {
|
||||
|
@ -7815,6 +7817,7 @@ noscript {
|
|||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
min-height: 36px;
|
||||
|
||||
.list_tag__display-name {
|
||||
flex-grow: 1;
|
||||
|
|
Loading…
Reference in New Issue