<label>{{cat.name()}}</label>
</div>
<div class="col-md-3 reg-field-input">
- <div ng-if="cat.entries().length == 0">
- <input
- ng-change="field_modified()"
- type="text" class="form-control"/>
- </div>
+
+ <!-- Editable typeahead is not support in this version of
+ angularjs-bootstrap. Requires Angular 1.4 and
+ angularjs-bootstrap version 1.1+ -->
+
+ <!-- typeahead is wonky. Consider updating -->
+ <!--
+ <input type="text" ng-model="stat_cat_entry_maps[cat.id()]"
+ typeahead="value as entry.value() for entry in cat.entries() | filter:$viewValue | limitTo:8"
+ class="form-control">
+ -->
+
<div ng-if="cat.entries().length != 0">
<div class="btn-group" dropdown>
<button type="button" class="btn btn-default dropdown-toggle">
<span style="padding-right: 5px;">
- {{stat_cat_entry_maps[cat.id()].value()}}</span>
+ {{stat_cat_entry_maps[cat.id()]}}</span>
<span class="caret"></span>
</button>
<ul class="dropdown-menu">
<li ng-repeat="entry in cat.entries()">
<a href
- ng-click="field_modified();stat_cat_entry_maps[cat.id()]=entry">
+ ng-click="field_modified();stat_cat_entry_maps[cat.id()]=entry.value()">
{{entry.value()}}
</a>
</li>
</div>
</div>
</div>
+
+ <!-- Stat cat retrieval API uses open-ils.storage under the covers
+ which represents DB bools at 1/0 instead of cstore-style t/f -->
+ <div class="col-md-3 reg-field-input" ng-if="cat.allow_freetext() == '1'">
+ <input type="text" ng-model="stat_cat_entry_maps[cat.id()]"/>
+ </div>
</div>
<!-- surveys -->
survey_answers : {},
survey_responses : {}, // survey.responses for loaded patron in progress
stat_cats : [],
- stat_cat_entry_maps : {}, // cat.id to selected entry object map
+ stat_cat_entry_maps : {}, // cat.id to selected value
virt_id : -1, // virtual ID for new objects
init_done : false // have we loaded our initialization data?
};
// toss entries for existing stat cat maps into our living
// stat cat entry map, which is modified within the template.
angular.forEach(patron.stat_cat_entries, function(map) {
- var entry;
- angular.forEach(service.stat_cats, function(cat) {
- angular.forEach(cat.entries(), function(ent) {
- if (ent.value() == map.stat_cat_entry)
- entry = ent;
- });
- });
- service.stat_cat_entry_maps[map.stat_cat.id] = entry;
+ service.stat_cat_entry_maps[map.stat_cat.id] = map.stat_cat_entry;
});
return patron;
});
patron.stat_cat_entries(maps);
- // service.stat_cat_entry_maps maps stats to entries
+ // service.stat_cat_entry_maps maps stats to values
// patron.stat_cat_entries is an array of stat_cat_entry_usr_map's
- angular.forEach(service.stat_cat_entry_maps, function(entry) {
+ angular.forEach(
+ service.stat_cat_entry_maps, function(value, cat_id) {
// see if we already have a mapping for this entry
- var existing = patron.stat_cat_entries().filter(function(e) {
- return e.stat_cat() == entry.stat_cat();
- })[0];
+ var existing = patron.stat_cat_entries().filter(
+ function(e) { return e.stat_cat() == cat_id })[0];
if (existing) { // we have a mapping
// if the existing mapping matches the new one,
// there' nothing left to do
- if (existing.stat_cat_entry() == entry.value()) return;
+ if (existing.stat_cat_entry() == value) return;
// mappings differ. delete the old one and create
// a new one below.
var newmap = new egCore.idl.actscecm();
newmap.target_usr(patron.id());
newmap.isnew(true);
- newmap.stat_cat(entry.stat_cat());
- newmap.stat_cat_entry(entry.value());
+ newmap.stat_cat(cat_id);
+ newmap.stat_cat_entry(value);
patron.stat_cat_entries().push(newmap);
});
- angular.forEach(patron.stat_cat_entries(), function(entry) {
- console.log(egCore.idl.toString(entry));
- });
-
if (!patron.isnew()) patron.ischanged(true);
return egCore.net.request(