Skip to content

Commit

Permalink
More linting stuff -_- wish I could get this to run locally.
Browse files Browse the repository at this point in the history
  • Loading branch information
jakkarth committed Mar 12, 2024
1 parent c08dfb1 commit a34d5c1
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 7 deletions.
8 changes: 4 additions & 4 deletions app/controllers/api/v1/lists/tags_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@ def load_tags
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)
Expand Down
21 changes: 18 additions & 3 deletions app/javascript/flavours/glitch/features/list_editor/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ const mapDispatchToProps = dispatch => ({
class ListEditor extends ImmutablePureComponent {
state = {
currentTab: 'accounts',
}
};

static propTypes = {
listId: PropTypes.string.isRequired,
onClose: PropTypes.func.isRequired,
Expand All @@ -60,15 +61,29 @@ 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;
return (
<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 />
Expand Down
3 changes: 3 additions & 0 deletions app/javascript/flavours/glitch/styles/components.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7791,6 +7791,8 @@ noscript {
padding: 5px;
background: $ui-base-color;
text-align: center;
border: 0;
color: $primary-text-color;
}

.tab.tab__active {
Expand All @@ -7815,6 +7817,7 @@ noscript {
display: flex;
justify-content: space-between;
align-items: center;
min-height: 36px;

.list_tag__display-name {
flex-grow: 1;
Expand Down

0 comments on commit a34d5c1

Please sign in to comment.