Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom item ordering and categorizing for the widget #167

Merged
merged 9 commits into from
Sep 18, 2017

Conversation

karthikb351
Copy link
Contributor

@karthikb351 karthikb351 commented Jul 9, 2017

Implements #166.

  • Customize the titles of rendered categories
  • Enforce ordering of items

Available via a new config categories

window.Boxoffice.init({
        org: 'hasgeek', // Organisation to show
        itemCollection: 'd386dbcf-1a32-11e7-b315-5d5ee7239cc7', // ItemCollection ID to show
        paymentDesc: 'HasGeek', // Description for payments widget
        categories: [
                    {
                        'name': 'conference',
                        'title': 'Standard',
                        'item_ids': ['68e27823-1a33-11e7-842a-85544f6e9ad9']
                    },
                    {
                        'name': 'premium',
                        'title': 'Premium',
                        'item_ids': ['63d94e70-1b3a-11e7-85fb-737e61409825','19e47ba8-1e8e-11e7-8f39-45cbac6935ba']
                    }
                ]
        ]
      });

An Item's name is unique in an item collection, and is human readable so I chose that over id


Examples

With categories

screen shot 2017-07-09 at 8 57 15 pm

window.Boxoffice.init({
        org: 'hasgeek', // Organisation to show
        itemCollection: 'd386dbcf-1a32-11e7-b315-5d5ee7239cc7', // ItemCollection ID to show
        paymentDesc: 'HasGeek', // Description for payments widget
        categories: [
                    {
                        'name': 'conference',
                        'title': 'Standard',
                        'item_ids': ['68e27823-1a33-11e7-842a-85544f6e9ad9']
                    },
                    {
                        'name': 'premium',
                        'title': 'Premium',
                        'item_ids': ['63d94e70-1b3a-11e7-85fb-737e61409825','19e47ba8-1e8e-11e7-8f39-45cbac6935ba']
                    }
                ]
      });

With duplicates and ordering

screen shot 2017-07-09 at 8 32 58 pm

window.Boxoffice.init({
        org: 'hasgeek', // Organisation to show
        itemCollection: 'd386dbcf-1a32-11e7-b315-5d5ee7239cc7', // ItemCollection ID to show
        paymentDesc: 'HasGeek', // Description for payments widget
        categories: [
                    {
                        'name': 'conference',
                        'title': 'Standard',
                        'item_ids': ['68e27823-1a33-11e7-842a-85544f6e9ad9']
                    },
                    {
                        'name': 'premium',
                        'title': 'Premium',
                        'item_ids': ['63d94e70-1b3a-11e7-85fb-737e61409825','19e47ba8-1e8e-11e7-8f39-45cbac6935ba']
                    }
                ]
      });

Without any value, defaults to server defined categories

screen shot 2017-07-09 at 8 33 22 pm

window.Boxoffice.init({
        org: 'hasgeek', // Organisation to show
        itemCollection: 'd386dbcf-1a32-11e7-b315-5d5ee7239cc7', // ItemCollection ID to show
        paymentDesc: 'HasGeek' // Description for payments widget
            }
        ]
      });

@vidya-ram
Copy link
Member

Wouldn't it better to do the filtering of items on the server side.

@vidya-ram
Copy link
Member

Here customising category on the client side involves overriding the existing categories and also classification of items. Wouldn't this lead to confusion.

@@ -165,10 +166,22 @@ $(function() {
}).done(function(data) {
var lineItems = [];

// Flag: If items have been explicitly specified in the config
var should_filter_items = (widgetConfig.categories && widgetConfig.categories.length > 0 ? true : false);
Copy link
Contributor

Choose a reason for hiding this comment

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

This line can just be widgetConfig.categories.length > 0.

@karthikb351
Copy link
Contributor Author

@shreyas-satish Works with ids instead of names - I've updated the example here to reflect that. Good to merge?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants