alchemymvc 1.2.8 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -142,6 +142,19 @@ Model.setProperty(function datasource() {
142
142
  return fallback_datasource;
143
143
  });
144
144
 
145
+ /**
146
+ * Does this model have translatable fields?
147
+ *
148
+ * @author Jelle De Loecker <jelle@elevenways.be>
149
+ * @since 1.3.0
150
+ * @version 1.3.0
151
+ *
152
+ * @type {Boolean}
153
+ */
154
+ Model.setProperty(function has_translatable_fields() {
155
+ return this.schema.has_translatable_fields;
156
+ });
157
+
145
158
  /**
146
159
  * The conduit
147
160
  *
@@ -349,7 +362,7 @@ Model.setProperty(function name() {
349
362
  *
350
363
  * @author Jelle De Loecker <jelle@develry.be>
351
364
  * @since 1.1.0
352
- * @version 1.1.0
365
+ * @version 1.3.0
353
366
  *
354
367
  * @param {Object} options
355
368
  */
@@ -371,7 +384,7 @@ Model.setMethod(function init(options) {
371
384
  }
372
385
 
373
386
  // Initialize behaviours
374
- if (this.schema && this.schema.hasBehaviours && this.initBehaviours) {
387
+ if (this.schema && this.schema.has_behaviours && this.initBehaviours) {
375
388
  this.initBehaviours();
376
389
  }
377
390
  });
@@ -568,7 +581,7 @@ Model.setMethod(function getAliasModel(alias) {
568
581
  *
569
582
  * @author Jelle De Loecker <jelle@develry.be>
570
583
  * @since 0.0.1
571
- * @version 1.2.5
584
+ * @version 1.3.0
572
585
  *
573
586
  * @param {String} type The type of find (first, all)
574
587
  * @param {Criteria} criteria The criteria object
@@ -626,10 +639,17 @@ Model.setMethod(function find(type, criteria, callback) {
626
639
  return pledge;
627
640
  }
628
641
 
642
+ if (this.conduit) {
643
+ criteria.conduit = this.conduit;
644
+ }
645
+
646
+ if (!criteria.options.locale && this.conduit) {
647
+ criteria.setOption('locale', this.conduit.prefix);
648
+ }
649
+
629
650
  let that = this,
630
651
  available,
631
652
  records,
632
- query,
633
653
  Type;
634
654
 
635
655
  // The criteria instance has to know about the model
@@ -1310,8 +1330,7 @@ Model.setMethod(function save(data, _options, _callback) {
1310
1330
  return iter.hasNext();
1311
1331
  }, function saveData(next) {
1312
1332
 
1313
- var document = iter.next().value,
1314
- temp;
1333
+ var document = iter.next().value;
1315
1334
 
1316
1335
  // Skip invalid items
1317
1336
  if (!document) {
@@ -1360,9 +1379,9 @@ Model.setMethod(function save(data, _options, _callback) {
1360
1379
  * Create a new document.
1361
1380
  * If data is given, the document is populated
1362
1381
  *
1363
- * @author Jelle De Loecker <jelle@develry.be>
1382
+ * @author Jelle De Loecker <jelle@elevenways.be>
1364
1383
  * @since 0.2.0
1365
- * @version 1.1.0
1384
+ * @version 1.3.0
1366
1385
  *
1367
1386
  * @param {Object} data Optional data
1368
1387
  * @param {Object} options
@@ -1371,13 +1390,15 @@ Model.setMethod(function save(data, _options, _callback) {
1371
1390
  */
1372
1391
  Model.setMethod(function createDocument(data, options) {
1373
1392
 
1374
- var doc;
1393
+ let original_record;
1375
1394
 
1376
1395
  if (!options) {
1377
1396
  options = {};
1378
1397
  }
1379
1398
 
1380
1399
  if (data && this.constructor.Document.isDocument(data)) {
1400
+ original_record = data.$attributes.original_record;
1401
+
1381
1402
  data = {
1382
1403
  [data.$model_alias] : data.$main,
1383
1404
  };
@@ -1385,7 +1406,11 @@ Model.setMethod(function createDocument(data, options) {
1385
1406
 
1386
1407
  options.model = this;
1387
1408
 
1388
- doc = new this.constructor.Document(data, options);
1409
+ let doc = new this.constructor.Document(data, options);
1410
+
1411
+ if (original_record) {
1412
+ doc.$attributes.original_record = original_record;
1413
+ }
1389
1414
 
1390
1415
  return doc;
1391
1416
  });
package/lib/bootstrap.js CHANGED
@@ -160,6 +160,7 @@ hawkejs_options.server = false;
160
160
  * @version 1.1.0
161
161
  */
162
162
  alchemy.hawkejs.load(libpath.resolve(PATH_CORE, 'class', 'path_definition.js'), hawkejs_options);
163
+ alchemy.hawkejs.load(libpath.resolve(PATH_CORE, 'class', 'path_param_definition.js'), hawkejs_options);
163
164
 
164
165
  /**
165
166
  * Require the element class on the client side too