Sha256: 3fa389bcfcc2174170c3627a30866fe8664201bd3260374da73fa537200d734c

Contents?: true

Size: 1.8 KB

Versions: 51

Compression:

Stored size: 1.8 KB

Contents

var FilterableShopList = React.createClass({

    getDefaultProps: function() {
        return {
            filterTabs: [
                { label: 'All Shops', filter: {} },
                { label: 'Installed', filter: { 'filter[status]': 'installed' } },
                { label: 'Uninstalled', filter: { 'filter[status]': 'uninstalled' } }
            ],
            availableFilters: {
                'filter[status]': {
                    getLabel: function(value) {
                        return 'Status is ' + value;
                    }
                }
            }
        }
    },

    getInitialState: function() {
        return {
            filter: {}
        };
    },

    onFilterReplace: function(filter) {
        this.setState({
            filter: filter
        });
    },

    onFilterSet: function(name, value) {
        this.onFiltersSet([{
            name: name,
            value: value
        }]);
    },

    onFiltersSet: function(filters) {
        var nextFilter = $.extend({}, this.state.filter);
        filters.forEach(function(filter) {
            if(!filter.value) {
                delete nextFilter[filter.name];
            } else {
                nextFilter[filter.name] = filter.value;
            }
        });
        this.onFilterReplace(nextFilter);
    },

    render: function() {
        return (
            <div className="next-card">
              <ShopFilterTabs filterTabs={this.props.filterTabs} filter={this.state.filter} onFilterReplace={this.onFilterReplace} />
              <ShopFilterQuery filter={this.state.filter} onFilterSet={this.onFilterSet} />
              <ShopList shopsUrl={this.props.shopsUrl} editShopUrl={this.props.editShopUrl} editSubscriptionUrl={this.props.editSubscriptionUrl} filter={this.state.filter} />
            </div>
        );
    }

});

Version data entries

51 entries across 51 versions & 1 rubygems

Version Path
disco_app-0.16.1.pre.sidekiq.pre.6.pre.release app/assets/javascripts/disco_app/components/custom/filterable_shop_list.js.jsx
disco_app-0.9.2 app/assets/javascripts/disco_app/components/custom/filterable_shop_list.js.jsx
disco_app-0.9.3 app/assets/javascripts/disco_app/components/custom/filterable_shop_list.js.jsx
disco_app-0.9.4 app/assets/javascripts/disco_app/components/custom/filterable_shop_list.js.jsx
disco_app-0.9.5 app/assets/javascripts/disco_app/components/custom/filterable_shop_list.js.jsx
disco_app-0.9.6 app/assets/javascripts/disco_app/components/custom/filterable_shop_list.js.jsx
disco_app-0.9.7 app/assets/javascripts/disco_app/components/custom/filterable_shop_list.js.jsx
disco_app-0.9.8 app/assets/javascripts/disco_app/components/custom/filterable_shop_list.js.jsx
disco_app-0.9.9 app/assets/javascripts/disco_app/components/custom/filterable_shop_list.js.jsx
disco_app-0.9.10 app/assets/javascripts/disco_app/components/custom/filterable_shop_list.js.jsx
disco_app-0.9.11 app/assets/javascripts/disco_app/components/custom/filterable_shop_list.js.jsx
disco_app-0.10.0 app/assets/javascripts/disco_app/components/custom/filterable_shop_list.js.jsx
disco_app-0.10.1 app/assets/javascripts/disco_app/components/custom/filterable_shop_list.js.jsx
disco_app-0.10.2 app/assets/javascripts/disco_app/components/custom/filterable_shop_list.js.jsx
disco_app-0.10.3 app/assets/javascripts/disco_app/components/custom/filterable_shop_list.js.jsx
disco_app-0.10.4 app/assets/javascripts/disco_app/components/custom/filterable_shop_list.js.jsx
disco_app-0.10.5 app/assets/javascripts/disco_app/components/custom/filterable_shop_list.js.jsx
disco_app-0.11.0 app/assets/javascripts/disco_app/components/custom/filterable_shop_list.js.jsx
disco_app-0.11.1 app/assets/javascripts/disco_app/components/custom/filterable_shop_list.js.jsx
disco_app-0.12.0 app/assets/javascripts/disco_app/components/custom/filterable_shop_list.js.jsx