Commits

ont  committed 6627889

(*) add searching via "/" command, fixing own add

  • Participants
  • Parent commits da41234

Comments (0)

Files changed (5)

         res.append(own)
 
     return pw2js(res, [
-        #'when',
+        'when',
         ('card',['name','pict','cost','cnum','power','tough',('cset',['name'])]),
     ])
 

File js/controllers.js

             });
 
         } else if( res[0] == 'del' ) {
+        } else if( res[0] == '/' ) {
+            //console.log('here');
+            $scope.m.filter = res[1];
+            $scope.$apply();
         }
     }
 
             };
             return res;
         });
-        console.log('b>>>>', res.value());
 
         /// then join cards with equal names in formed groups
         if( $scope.m.join )
                     return tmp;
                 }).value();
             });
-        console.log('a>>>>', res.value());
 
         $scope.owns_m = res.value();  // convert lo-dash to usual array
         //console.log(res.value());

File js/modules.js

             templateUrl: 'tpl/cards_my.html',
             controller: 'CardsListCtrl',
             resolve: {
-                'user' : function(Restangular){
-                    return Restangular.all('users').get('current');  // inject current user
+                'user' : function(Restangular, authService){
+                    var user = Restangular.all('users').get('current');
+                    user.then(function(user){
+                        console.log('pppp>', user);
+                        authService.user = user;  // inject current user
+                    });
+                    return user;
                 }
             }
         }).
 start
-  = add_cmd / del_cmd
+  = add_cmd / del_cmd / search_cmd
  
 add_cmd
   = act:"add"i " "* cnt:cnt? " "* names:card_name {return [act, cnt, names]}
 del_cmd
   = act:"del"i " "* cnt:cnt? " "* name:card_name {return [act, cnt, name]}
  
+search_cmd
+  = act:"/"i " "* txt:txt {return [act, txt]}
+
 card_name
   = " "* '"' name:[^|]+ '|' set:[^"]+ '"' " "* { return [name.join(""), set.join("")] }
  
 cnt
   = digits:[0-9]+ {return parseInt(digits.join(""), 10)}
+
+txt
+  = chars:.* { return chars.join("") }

File tpl/_cards_list.html

-<div class="row" ng-repeat="grp in owns_m | orderBy:'-value'">
-    <div class="large-12 columns">
-        <div ng-switch="dmode" class="panel mtg-box">
-            <div ng-show="show_labels()" class="label radius mtg-side-info-90">
-                {{grp.value_label}}<sup>{{m.sort[0]}}</sup>
+<div>
+    <div ng-show="m.filter" class="row">
+        <div class="large-12 columns">
+            <div class="label small">filtered by: {{m.filter}}</div>
+        </div>
+    </div>
+    <div class="row" ng-repeat="grp in owns_m | orderBy:'-value'">
+        <div class="large-12 columns">
+            <div ng-switch="dmode" class="panel mtg-box">
+                <div ng-show="show_labels()" class="label radius mtg-side-info-90">
+                    {{grp.value_label}}<sup>{{m.sort[0]}}</sup>
+                </div>
+                <ul ng-switch-when="short" class="large-block-grid-3 mtg-cards-grid">
+                    <li ng-repeat="own in grp.owns | orderBy:get_sorters() | filter:m.filter">
+                        {{own.card.name}} [{{own.card.power}} / {{own.card.tough}}]
+                    </li>
+                </ul>
+                <ul ng-switch-when="thumb" class="large-block-grid-6 mtg-cards-grid">
+                    <li ng-repeat="own in grp.owns | orderBy:get_sorters() | filter:m.filter">
+                        <span ng-show="own.cnt > 1" class="secondary label mtg-card-cnt">{{own.cnt}}</span>
+                        <span class="mtg-zoom">
+                            <img ng-src="{{own.card.pict}}"/>
+                            <img ng-src="{{own.card.pict}}"/>
+                        </span>
+                    </li>
+                </ul>
             </div>
-            <ul ng-switch-when="short" class="large-block-grid-3 mtg-cards-grid">
-                <li ng-repeat="own in grp.owns | orderBy:get_sorters()">
-                    {{own.card.name}} [{{own.card.power}} / {{own.card.tough}}]
-                </li>
-            </ul>
-            <ul ng-switch-when="thumb" class="large-block-grid-6 mtg-cards-grid">
-                <li ng-repeat="own in grp.owns | orderBy:get_sorters()">
-                    <span ng-show="own.cnt > 1" class="secondary label mtg-card-cnt">{{own.cnt}}</span>
-                    <span class="mtg-zoom">
-                        <img ng-src="{{own.card.pict}}"/>
-                        <img ng-src="{{own.card.pict}}"/>
-                    </span>
-                </li>
-            </ul>
         </div>
     </div>
 </div>
-