Under some circumstances, the current code can result in a JS failure:
Cannot read property 'filter' of undefined
When this happens, the copy template may apply partially or not at all.
This change simply makes sure cp.stat_cat_entries() exists before
attempting to filter it.
Signed-off-by: Jeff Davis <jdavis@sitka.bclibraries.ca>
Signed-off-by: Dan Wells <dbw2@calvin.edu>
// trim out all deleted ones; the API used to
// do the update doesn't actually consult
// isdeleted for stat cat entries
- cp.stat_cat_entries(
- cp.stat_cat_entries().filter(function (e) {
- return !Boolean(e.isdeleted());
- })
- );
+ if (cp.stat_cat_entries()) {
+ cp.stat_cat_entries(
+ cp.stat_cat_entries().filter(function (e) {
+ return !Boolean(e.isdeleted());
+ })
+ );
+ }
cp.ischanged(1);
}