kea-rails 1.0.2 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 62878c06064a75c5ba32b0124fd8075bfbb61d9c
4
- data.tar.gz: 9065346008a3ce4a18efbca79ddb4a0d5f131afd
3
+ metadata.gz: db25fa7e45c049047b286a2ac55bbf6e54453dfb
4
+ data.tar.gz: 57183ee67ad44d8544dbe545e5cebe9e5b153bce
5
5
  SHA512:
6
- metadata.gz: d4934d1984fa982d4c5a3d47813e3cf076a8bb055072513c7f50603908381156faf1a6304de92837990cf50f4d6a199d0c811f533e3de1aa500df245ed657d7c
7
- data.tar.gz: 95dc7203b13a0e1e1cd11b020048a75c8bb5404411fc39dfc8c49c2aab8ee690c3a2f24add3b1b3249e0223aba97b5e99f0ec37c75cc95d998c67c50c37c9f5e
6
+ metadata.gz: d0c5da927c46a7d09bda7211ea2683b526a869c5efbc2f5a210befd08003c950eeeeb9e3bef9619b835c1870c581dccac0b15cc85211f273c736a85c1f5267ac
7
+ data.tar.gz: 1b6238338f64629bd0f9f563082860d185d429f06a91b9a9cda39bd84df331a6d49568235e2b31a2b6abf8f7674619d80e28c0acc79fffa669e33719c6bd4039
@@ -4,12 +4,12 @@
4
4
  ko.bindingHandlers.sherlock = {
5
5
  init: function(element, valueAccessor, allBindingsAccessor, viewModel, bindingContext) {
6
6
  var $container = $(element),
7
- options = ko.unwrap(valueAccessor()),
7
+ options = typeof ko.unwrap(valueAccessor()) === 'object' ? ko.unwrap(valueAccessor()) : {},
8
8
  $providerSearchField,
9
9
  sherlockVm;
10
10
 
11
11
  sherlockVm = new app.sherlock.SherlockVm();
12
- sherlockVm.setup();
12
+ sherlockVm.setup(options);
13
13
 
14
14
  sherlockVm.params.subscribe(function(params) {
15
15
  bindingContext.$data.sherlockParams(params);
@@ -9,11 +9,12 @@
9
9
 
10
10
  var that = this;
11
11
 
12
- this.providers = ko.observableArray([]);
13
- this.providerSearchTerm = ko.observable('').extend({ rateLimit: { timeout: 500, method: "notifyWhenChangesStop" } });
14
- this.providerSearchActive = ko.observable(false);
15
- this.showLiveSearchWidgets = ko.observable(false);
16
- this.activeFragments = ko.observableArray([]);
12
+ this.options = ko.observable();
13
+ this.providers = ko.observableArray([]);
14
+ this.providerSearchTerm = ko.observable('').extend({ rateLimit: { timeout: 500, method: "notifyWhenChangesStop" } });
15
+ this.providerSearchActive = ko.observable(false);
16
+ this.showLiveSearchWidgets = ko.observable(false);
17
+ this.activeFragments = ko.observableArray([]);
17
18
 
18
19
  this.params = ko.computed(function() {
19
20
  var params = {};
@@ -216,11 +217,23 @@
216
217
  }
217
218
  });
218
219
 
219
- this.setup = function setup() {
220
- for (var providerName in app.sherlock.providers) {
221
- if (app.sherlock.providers.hasOwnProperty(providerName)) {
220
+ this.setup = function setup(options) {
221
+ that.options(options || {});
222
+
223
+ if (that.options().providers) {
224
+
225
+ that.options().providers.forEach(function(providerName) {
222
226
  that.providers.push( new app.sherlock.providers[providerName]() );
223
- }
227
+ });
228
+
229
+ } else {
230
+
231
+ for (var providerName in app.sherlock.providers) {
232
+ if (app.sherlock.providers.hasOwnProperty(providerName)) {
233
+ that.providers.push( new app.sherlock.providers[providerName]() );
234
+ }
235
+ }
236
+
224
237
  }
225
238
  };
226
239
  };
@@ -0,0 +1,54 @@
1
+ <script id="sherlock-container-template" type="text/html">
2
+ <!-- ko foreach: activeFragments -->
3
+ <div class="fragment" data-bind="template: {name: provider.fragment_template_name, afterRender: function(nodes, fragment) { if (!fragment.searchValue()) { $(nodes).filter('[data-focus-after-render]').focus(); } }}, click: function(fragment, ev) { ev.stopPropagation(); return true; }"></div>
4
+ <!-- /ko -->
5
+ <div data-bind="sherlockProviderSearch: $data" class="provider-search-field">
6
+ <input type="text" data-bind="value: providerSearchTerm, valueUpdate: 'keyup'">
7
+ <div class="provider-search-dropdown">
8
+ <ul data-bind="foreach: orderedFragmentsForSearchTerm">
9
+ <li data-bind="html: displayString, click: $parent.selectFragment.bind($parent, $data), css: { 'has-focus': hasFocus }, clickBubble: false"></li>
10
+ </ul>
11
+ <div data-bind="foreach: liveSearchProviders, visible: showLiveSearchWidgets">
12
+ <!-- ko template: livesearch_template_name --><!-- /ko -->
13
+ </div>
14
+ </div>
15
+ </div>
16
+ </script>
17
+
18
+ <script id="sherlock-base-fragment-template" type=="text/html">
19
+ <span class="fragment-name" data-bind="text: provider.displayName + ':'"></span>
20
+ <!-- ko if: changeable -->
21
+ <!-- ko if: predicateOptions().length > 0 -->
22
+ <select class="fragment-predicate" data-bind="value: predicate, options: predicateOptions, optionsText: 'label', optionsValue: 'value'" data-focus-after-render="true"></select>
23
+ <input type="text" data-bind="value: searchValue" class="fragment-search-value">
24
+ <!-- /ko -->
25
+ <!-- ko if: predicateOptions().length === 0 -->
26
+ <input type="text" data-bind="value: searchValue" data-focus-after-render="true" class="fragment-search-value">
27
+ <!-- /ko -->
28
+ <!-- /ko -->
29
+ <!-- ko if: !changeable -->
30
+ <div class="fragment-search-value-display" data-bind="text: searchValueDisplay"></div>
31
+ <!-- /ko -->
32
+ <button class="icon-button fragment-remove" data-bind="click: $parent.removeFragment.bind($parent, $data), clickBubble: false"><i class="icon-cancel-circled"></i></button>
33
+ </script>
34
+
35
+ <script id="sherlock-base-dropdown-fragment-template" type=="text/html">
36
+ <span class="fragment-name" data-bind="text: provider.displayName + ':'"></span>
37
+ <!-- ko if: changeable -->
38
+ <select class="fragment-search-value" data-bind="value: searchValue, options: searchValueOptions, optionsText: 'label', optionsValue: 'value'" data-focus-after-render="true"></select>
39
+ <!-- /ko -->
40
+ <!-- ko if: !changeable -->
41
+ <div class="fragment-search-value-display" data-bind="text: searchValueDisplay"></div>
42
+ <!-- /ko -->
43
+ <button class="icon-button fragment-remove" data-bind="click: $parent.removeFragment.bind($parent, $data), clickBubble: false"><i class="icon-cancel-circled"></i></button>
44
+ </script>
45
+
46
+ <script id="sherlock-base-livesearch-template" type=="text/html">
47
+ <article data-bind="visible: liveSearchVisible">
48
+ <h2 data-bind="text: displayName"></h2>
49
+ <span data-bind="activity: liveSearchAjaxActivity" class="activity-indicator"></span>
50
+ <ul data-bind="foreach: liveSearchFragments">
51
+ <li data-bind="html: displayString, click: $parents[1].selectFragment.bind($parents[1], $data), css: { 'has-focus': hasFocus }, clickBubble: false"></li>
52
+ </ul>
53
+ </article>
54
+ </script>
@@ -40,7 +40,7 @@ $standard-border-color-on-dark: $grey-10 !default
40
40
  background-color: $primary-highlight-color
41
41
  color: $text-on-dark
42
42
  line-height: 40px
43
- .fragment-search-value
43
+ .fragment-search-value, .fragment-predicate
44
44
  padding: 0 0.5rem
45
45
  font-size: $base-font-size
46
46
  border: none
@@ -1,4 +1,4 @@
1
- (function(app, ko) {
1
+ (function(app, kea, ko) {
2
2
  "use strict";
3
3
 
4
4
  var viewmodel_name = '<%= name.camelize %>',
@@ -70,4 +70,4 @@
70
70
 
71
71
  app.viewmodels[viewmodel_name] = ViewmodelClass;
72
72
 
73
- })(window.app, ko);
73
+ })(window.app, window.kea, ko);
@@ -1,3 +1,3 @@
1
1
  module Kea
2
- VERSION = "1.0.2"
2
+ VERSION = "1.0.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kea-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jan-Christian Foeh
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-31 00:00:00.000000000 Z
11
+ date: 2015-02-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -66,6 +66,7 @@ files:
66
66
  - app/assets/javascripts/kea/viewmodels/sherlock.js
67
67
  - app/assets/stylesheets/kea/kea.css.sass
68
68
  - app/helpers/kea/application_helper.rb
69
+ - app/views/sherlock/_templates.html.erb
69
70
  - lib/generators/kea/install/USAGE
70
71
  - lib/generators/kea/install/install_generator.rb
71
72
  - lib/generators/kea/install/templates/_komplete.sass
@@ -79,7 +80,7 @@ files:
79
80
  - lib/generators/kea/model/templates/model.js.erb
80
81
  - lib/generators/kea/service/USAGE
81
82
  - lib/generators/kea/service/service_generator.rb
82
- - lib/generators/kea/service/templates/model.js.erb
83
+ - lib/generators/kea/service/templates/service.js.erb
83
84
  - lib/generators/kea/viewmodel/USAGE
84
85
  - lib/generators/kea/viewmodel/templates/viewmodel.js.erb
85
86
  - lib/generators/kea/viewmodel/viewmodel_generator.rb