~rharding/juju-gui/charm-details-1172050

« back to all changes in this revision

Viewing changes to app/subapps/browser/views/view.js

Adds search functionality

This adds text search from the search widget
-Search widget propogates search text to browser subapp
-Subapp routes data to search view
-Search view does query from text
-Search view can render search results

As a driveby, this moves repeated apiFailure code out to an extension.

There is an issue outstanding:
-The querystring can be eaten by the routing code in some cases. A follow up
branch is in progress for this problem.

R=rharding, jeff.pihach, curtis
CC=
https://codereview.appspot.com/8910043

Show diffs side-by-side

added added

removed removed

Lines of Context:
107
107
     *
108
108
     */
109
109
    _searchChanged: function(ev) {
110
 
      console.log('search changed.');
 
110
      // NB: This is temporary; eventually filtering will include categories,
 
111
      // and the Filter object will handle qs generation. But it's an unwieldy
 
112
      // url to parse while we only support text search.
 
113
      var qs = Y.QueryString.stringify({text: ev.details[0]});
 
114
      var change = {
 
115
        search: true,
 
116
        querystring: qs
 
117
      };
 
118
      this.fire('viewNavigate', {
 
119
        change: change
 
120
      });
111
121
    },
112
122
 
113
123
    /**
151
161
    },
152
162
 
153
163
    /**
154
 
     * Shared method to generate a message to the user based on a bad api
155
 
     * call.
156
 
     *
157
 
     * @method apiFailure
158
 
     * @param {Object} data the json decoded response text.
159
 
     * @param {Object} request the original io_request object for debugging.
160
 
     *
161
 
     */
162
 
    apiFailure: function(data, request) {
163
 
      var message;
164
 
      if (data && data.type) {
165
 
        message = 'Charm API error of type: ' + data.type;
166
 
      } else {
167
 
        message = 'Charm API server did not respond';
168
 
      }
169
 
      this.get('db').notifications.add(
170
 
          new models.Notification({
171
 
            title: 'Failed to load sidebar content.',
172
 
            message: message,
173
 
            level: 'error'
174
 
          })
175
 
      );
176
 
    },
177
 
 
178
 
    /**
179
164
     * Destroy this view and clear from the dom world.
180
165
     *
181
166
     * @method destructor
269
254
    'event-tracker',
270
255
    'juju-charm-store',
271
256
    'juju-models',
 
257
    'querystring-stringify',
272
258
    'view'
273
259
  ]
274
260
});