alchemymvc 1.3.11 → 1.3.13
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.
- package/LICENSE +0 -0
- package/README.md +0 -0
- package/lib/app/assets/scripts/.gitkeep +0 -0
- package/lib/app/assets/stylesheets/alchemy-info.less +0 -0
- package/lib/app/behaviour/publishable_behaviour.js +0 -0
- package/lib/app/behaviour/revision_behaviour.js +0 -0
- package/lib/app/behaviour/sluggable_behaviour.js +0 -0
- package/lib/app/component/.gitkeep +0 -0
- package/lib/app/conduit/electron_conduit.js +0 -0
- package/lib/app/conduit/http_conduit.js +0 -0
- package/lib/app/conduit/loopback_conduit.js +0 -0
- package/lib/app/conduit/socket_conduit.js +0 -0
- package/lib/app/controller/alchemy_info_controller.js +0 -0
- package/lib/app/datasource/mongo_datasource.js +0 -0
- package/lib/app/element/time_ago.js +0 -0
- package/lib/app/helper/alchemy_helper.js +0 -0
- package/lib/app/helper/backed_map.js +0 -0
- package/lib/app/helper/breadcrumb.js +0 -0
- package/lib/app/helper/client_collection.js +0 -0
- package/lib/app/helper/enum_values.js +0 -0
- package/lib/app/helper/pagination_helper.js +0 -0
- package/lib/app/helper/router_helper.js +0 -0
- package/lib/app/helper/socket_helper.js +2 -2
- package/lib/app/helper/syncable.js +0 -0
- package/lib/app/helper_component/paginate_component.js +0 -0
- package/lib/app/helper_controller/component.js +0 -0
- package/lib/app/helper_controller/conduit.js +0 -0
- package/lib/app/helper_controller/controller.js +0 -0
- package/lib/app/helper_datasource/00-nosql_datasource.js +0 -0
- package/lib/app/helper_datasource/05-fallback_datasource.js +0 -0
- package/lib/app/helper_datasource/idb_datasource.js +0 -0
- package/lib/app/helper_datasource/indexed_db.js +0 -0
- package/lib/app/helper_datasource/remote_datasource.js +0 -0
- package/lib/app/helper_error/http_error.js +0 -0
- package/lib/app/helper_error/model_error.js +0 -0
- package/lib/app/helper_error/validation_error.js +0 -0
- package/lib/app/helper_field/00-objectid_field.js +0 -0
- package/lib/app/helper_field/05-string_field.js +0 -0
- package/lib/app/helper_field/06-text_field.js +0 -0
- package/lib/app/helper_field/10-number_field.js +0 -0
- package/lib/app/helper_field/belongsto_field.js +0 -0
- package/lib/app/helper_field/big_int_field.js +0 -0
- package/lib/app/helper_field/boolean_field.js +0 -0
- package/lib/app/helper_field/date_field.js +0 -0
- package/lib/app/helper_field/datetime_field.js +0 -0
- package/lib/app/helper_field/enum_field.js +0 -0
- package/lib/app/helper_field/geopoint_field.js +0 -0
- package/lib/app/helper_field/habtm_field.js +0 -0
- package/lib/app/helper_field/hasoneparent_field.js +0 -0
- package/lib/app/helper_field/html_field.js +0 -0
- package/lib/app/helper_field/integer_field.js +0 -0
- package/lib/app/helper_field/object_field.js +0 -0
- package/lib/app/helper_field/password_field.js +0 -0
- package/lib/app/helper_field/regexp_field.js +0 -0
- package/lib/app/helper_field/schema_field.js +0 -0
- package/lib/app/helper_field/time_field.js +0 -0
- package/lib/app/helper_field/url_field.js +0 -0
- package/lib/app/helper_model/criteria.js +0 -0
- package/lib/app/helper_model/data_provider.js +18 -1
- package/lib/app/helper_model/db_query.js +0 -0
- package/lib/app/helper_model/document.js +36 -0
- package/lib/app/helper_model/document_list.js +0 -0
- package/lib/app/helper_model/field_config.js +0 -0
- package/lib/app/helper_model/field_set.js +0 -0
- package/lib/app/helper_model/model.js +35 -5
- package/lib/app/helper_model/remote_data_provider.js +64 -6
- package/lib/app/helper_validator/00_validator.js +0 -0
- package/lib/app/helper_validator/not_empty_validator.js +0 -0
- package/lib/app/model/alchemy_migration_model.js +0 -0
- package/lib/app/model/alchemy_task_model.js +0 -0
- package/lib/app/routes.js +0 -0
- package/lib/app/view/alchemy/info.hwk +0 -0
- package/lib/app/view/error/unknown.ejs +0 -0
- package/lib/app/view/paginate/navlist.ejs +0 -0
- package/lib/bootstrap.js +0 -0
- package/lib/class/behaviour.js +0 -0
- package/lib/class/component.js +0 -0
- package/lib/class/conduit.js +14 -4
- package/lib/class/controller.js +0 -0
- package/lib/class/datasource.js +0 -0
- package/lib/class/document.js +0 -0
- package/lib/class/document_list.js +0 -0
- package/lib/class/element.js +0 -0
- package/lib/class/error.js +0 -0
- package/lib/class/field.js +0 -0
- package/lib/class/field_value.js +0 -0
- package/lib/class/helper.js +0 -0
- package/lib/class/inode.js +0 -0
- package/lib/class/inode_dir.js +0 -0
- package/lib/class/inode_file.js +0 -0
- package/lib/class/inode_list.js +0 -0
- package/lib/class/migration.js +0 -0
- package/lib/class/model.js +0 -0
- package/lib/class/path_definition.js +0 -0
- package/lib/class/path_evaluator.js +0 -0
- package/lib/class/path_param_definition.js +2 -2
- package/lib/class/postponement.js +0 -0
- package/lib/class/reciprocal.js +0 -0
- package/lib/class/route.js +0 -0
- package/lib/class/router.js +0 -0
- package/lib/class/schema.js +0 -0
- package/lib/class/schema_client.js +0 -0
- package/lib/class/session.js +0 -0
- package/lib/class/session_scene.js +0 -0
- package/lib/class/sitemap.js +0 -0
- package/lib/class/task.js +0 -0
- package/lib/core/base.js +0 -0
- package/lib/core/client_alchemy.js +57 -0
- package/lib/core/client_base.js +0 -0
- package/lib/core/discovery.js +0 -0
- package/lib/core/middleware.js +0 -0
- package/lib/core/routing.js +0 -0
- package/lib/core/socket.js +0 -0
- package/lib/init/alchemy.js +0 -0
- package/lib/init/constants.js +0 -0
- package/lib/init/devwatch.js +0 -0
- package/lib/init/functions.js +0 -0
- package/lib/init/load_functions.js +0 -0
- package/lib/init/requirements.js +0 -0
- package/lib/stages.js +0 -0
- package/package.json +1 -1
package/LICENSE
CHANGED
|
File without changes
|
package/README.md
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -352,7 +352,7 @@ Client.setMethod(function createStream() {
|
|
|
352
352
|
*
|
|
353
353
|
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
354
354
|
* @since 0.2.0
|
|
355
|
-
* @version 1.3.
|
|
355
|
+
* @version 1.3.12
|
|
356
356
|
*
|
|
357
357
|
* @param {Function} callback
|
|
358
358
|
*/
|
|
@@ -386,7 +386,7 @@ Client.setMethod(function connect(address, data, callback) {
|
|
|
386
386
|
|
|
387
387
|
if (typeof io != 'undefined') {
|
|
388
388
|
io_client = io;
|
|
389
|
-
} else if (typeof alchemy
|
|
389
|
+
} else if (typeof alchemy?.use == 'function') {
|
|
390
390
|
io_client = alchemy.use('socket.io-client');
|
|
391
391
|
} else {
|
|
392
392
|
return callback(new Error('Could not find socket.io client library'));
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -9,7 +9,6 @@ const DataProvider = Function.inherits('Alchemy.Base', 'Alchemy.DataProvider', f
|
|
|
9
9
|
this.config = config || {};
|
|
10
10
|
});
|
|
11
11
|
|
|
12
|
-
|
|
13
12
|
/**
|
|
14
13
|
* Undry
|
|
15
14
|
*
|
|
@@ -47,6 +46,15 @@ DataProvider.setStatic(function addConfig(name, default_value) {
|
|
|
47
46
|
});
|
|
48
47
|
});
|
|
49
48
|
|
|
49
|
+
/**
|
|
50
|
+
* Extra context
|
|
51
|
+
*
|
|
52
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
53
|
+
* @since 1.3.12
|
|
54
|
+
* @version 1.3.12
|
|
55
|
+
*/
|
|
56
|
+
DataProvider.addConfig('context');
|
|
57
|
+
|
|
50
58
|
/**
|
|
51
59
|
* The wanted page size
|
|
52
60
|
*
|
|
@@ -74,6 +82,15 @@ DataProvider.setAbstractMethod('getAll');
|
|
|
74
82
|
*/
|
|
75
83
|
DataProvider.setAbstractMethod('getPage');
|
|
76
84
|
|
|
85
|
+
/**
|
|
86
|
+
* Get a single data by id (or other unique identifier)
|
|
87
|
+
*
|
|
88
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
89
|
+
* @since 1.2.2
|
|
90
|
+
* @version 1.2.2
|
|
91
|
+
*/
|
|
92
|
+
DataProvider.setAbstractMethod('getById');
|
|
93
|
+
|
|
77
94
|
/**
|
|
78
95
|
* Return an object for json-drying this document
|
|
79
96
|
*
|
|
File without changes
|
|
@@ -636,6 +636,42 @@ Document.setMethod(function toDry() {
|
|
|
636
636
|
};
|
|
637
637
|
}, false);
|
|
638
638
|
|
|
639
|
+
/**
|
|
640
|
+
* Get the displaytitle of this document, or null
|
|
641
|
+
*
|
|
642
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
643
|
+
* @since 1.3.13
|
|
644
|
+
* @version 1.3.14
|
|
645
|
+
*
|
|
646
|
+
* @return {String}
|
|
647
|
+
*/
|
|
648
|
+
Document.setMethod(function getDisplayTitleOrNull() {
|
|
649
|
+
|
|
650
|
+
if (this.$model) {
|
|
651
|
+
return this.$model.getDisplayTitleOrNull(this);
|
|
652
|
+
}
|
|
653
|
+
|
|
654
|
+
return null;
|
|
655
|
+
});
|
|
656
|
+
|
|
657
|
+
/**
|
|
658
|
+
* Get the displaytitle of this document
|
|
659
|
+
*
|
|
660
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
661
|
+
* @since 1.3.13
|
|
662
|
+
* @version 1.3.14
|
|
663
|
+
*
|
|
664
|
+
* @return {String}
|
|
665
|
+
*/
|
|
666
|
+
Document.setMethod(function getDisplayTitle() {
|
|
667
|
+
|
|
668
|
+
if (this.$model) {
|
|
669
|
+
return this.$model.getDisplayTitle(this);
|
|
670
|
+
}
|
|
671
|
+
|
|
672
|
+
return '';
|
|
673
|
+
});
|
|
674
|
+
|
|
639
675
|
/**
|
|
640
676
|
* Actually initialize this instance
|
|
641
677
|
*
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -452,23 +452,22 @@ Model.setMethod(function getFindOptions(options) {
|
|
|
452
452
|
return Object.assign({}, def_options, options);
|
|
453
453
|
});
|
|
454
454
|
|
|
455
|
-
|
|
456
455
|
/**
|
|
457
456
|
* Get the title to display for this record
|
|
458
457
|
*
|
|
459
458
|
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
460
459
|
* @since 0.0.1
|
|
461
|
-
* @version 1.
|
|
460
|
+
* @version 1.3.14
|
|
462
461
|
*
|
|
463
462
|
* @param {Object} item The record item of this model
|
|
464
463
|
* @param {String|Array} fallbacks Extra fallbacks to use
|
|
465
464
|
*
|
|
466
465
|
* @return {String} The display title to use
|
|
467
466
|
*/
|
|
468
|
-
Model.setMethod(function
|
|
467
|
+
Model.setMethod(function getDisplayTitleOrNull(item, fallbacks) {
|
|
469
468
|
|
|
470
469
|
if (!item) {
|
|
471
|
-
return
|
|
470
|
+
return null;
|
|
472
471
|
}
|
|
473
472
|
|
|
474
473
|
let main;
|
|
@@ -509,7 +508,38 @@ Model.setMethod(function getDisplayTitle(item, fallbacks) {
|
|
|
509
508
|
}
|
|
510
509
|
}
|
|
511
510
|
|
|
512
|
-
return
|
|
511
|
+
return null;
|
|
512
|
+
});
|
|
513
|
+
|
|
514
|
+
/**
|
|
515
|
+
* Get the title to display for this record
|
|
516
|
+
*
|
|
517
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
518
|
+
* @since 0.0.1
|
|
519
|
+
* @version 1.3.14
|
|
520
|
+
*
|
|
521
|
+
* @param {Object} item The record item of this model
|
|
522
|
+
* @param {String|Array} fallbacks Extra fallbacks to use
|
|
523
|
+
*
|
|
524
|
+
* @return {String} The display title to use
|
|
525
|
+
*/
|
|
526
|
+
Model.setMethod(function getDisplayTitle(item, fallbacks) {
|
|
527
|
+
|
|
528
|
+
if (!item) {
|
|
529
|
+
return 'Undefined item';
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
let result = this.getDisplayTitleOrNull(item, fallbacks);
|
|
533
|
+
|
|
534
|
+
if (result == null) {
|
|
535
|
+
result = main[this.primary_key] || '';
|
|
536
|
+
|
|
537
|
+
if (result && typeof result != 'string') {
|
|
538
|
+
result = '' + result;
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
return result;
|
|
513
543
|
});
|
|
514
544
|
|
|
515
545
|
/**
|
|
@@ -17,19 +17,77 @@ const RemoteDataProvider = Function.inherits('Alchemy.DataProvider', 'Remote');
|
|
|
17
17
|
RemoteDataProvider.addConfig('source');
|
|
18
18
|
|
|
19
19
|
/**
|
|
20
|
-
*
|
|
20
|
+
* Do a fetch
|
|
21
21
|
*
|
|
22
22
|
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
23
|
-
* @since 1.
|
|
24
|
-
* @version 1.
|
|
23
|
+
* @since 1.3.13
|
|
24
|
+
* @version 1.3.13
|
|
25
|
+
*
|
|
26
|
+
* @return {Pledge|Array}
|
|
25
27
|
*/
|
|
26
|
-
RemoteDataProvider.setMethod(
|
|
28
|
+
RemoteDataProvider.setMethod(function performSourceRequest(type, options) {
|
|
27
29
|
|
|
28
30
|
if (!this.source) {
|
|
29
31
|
return [];
|
|
30
32
|
}
|
|
31
33
|
|
|
32
|
-
|
|
34
|
+
if (!options) {
|
|
35
|
+
options = {};
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
if (!options.get) {
|
|
39
|
+
options.get = {};
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if (this.context) {
|
|
43
|
+
options.get.context = this.context;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
options.get.provider_method = type;
|
|
47
|
+
|
|
48
|
+
return alchemy.fetch(this.source, options);
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Get all the data
|
|
53
|
+
*
|
|
54
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
55
|
+
* @since 1.2.2
|
|
56
|
+
* @version 1.3.13
|
|
57
|
+
*/
|
|
58
|
+
RemoteDataProvider.setMethod(function getAll() {
|
|
59
|
+
return this.performSourceRequest('all');
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Get a specific id
|
|
64
|
+
*
|
|
65
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
66
|
+
* @since 1.2.2
|
|
67
|
+
* @version 1.3.13
|
|
68
|
+
*/
|
|
69
|
+
RemoteDataProvider.setMethod(function getById(id) {
|
|
70
|
+
return this.performSourceRequest('by_id', {
|
|
71
|
+
get: {
|
|
72
|
+
id: id,
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
});
|
|
33
76
|
|
|
34
|
-
|
|
77
|
+
/**
|
|
78
|
+
* Get a specific page
|
|
79
|
+
*
|
|
80
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
81
|
+
* @since 1.2.2
|
|
82
|
+
* @version 1.3.13
|
|
83
|
+
*
|
|
84
|
+
* @param {Number} page 1-indexed page number
|
|
85
|
+
*/
|
|
86
|
+
RemoteDataProvider.setMethod(function getPage(page) {
|
|
87
|
+
return this.performSourceRequest('page', {
|
|
88
|
+
get: {
|
|
89
|
+
page : page,
|
|
90
|
+
page_size: this.page_size,
|
|
91
|
+
}
|
|
92
|
+
});
|
|
35
93
|
});
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/lib/app/routes.js
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/lib/bootstrap.js
CHANGED
|
File without changes
|
package/lib/class/behaviour.js
CHANGED
|
File without changes
|
package/lib/class/component.js
CHANGED
|
File without changes
|
package/lib/class/conduit.js
CHANGED
|
@@ -2033,7 +2033,7 @@ Conduit.setTypedMethod([Types.String, Types.Object.optional()], function serveFi
|
|
|
2033
2033
|
*
|
|
2034
2034
|
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
2035
2035
|
* @since 0.2.0
|
|
2036
|
-
* @version 1.3.
|
|
2036
|
+
* @version 1.3.13
|
|
2037
2037
|
*
|
|
2038
2038
|
* @param {Alchemy.Inode.File} file The file to serve
|
|
2039
2039
|
* @param {Object} options Options, including headers
|
|
@@ -2043,12 +2043,17 @@ Conduit.setTypedMethod([Types.Alchemy.Inode.File, Types.Object.optional()], asyn
|
|
|
2043
2043
|
if (file.path && !FILECACHE.has(file.path)) {
|
|
2044
2044
|
FILECACHE.set(file.path, file);
|
|
2045
2045
|
}
|
|
2046
|
-
|
|
2046
|
+
|
|
2047
|
+
let stats = await file.getStats();
|
|
2048
|
+
|
|
2047
2049
|
if (alchemy.settings.cache && (!options.cache_time && options.cache_time !== false)) {
|
|
2048
|
-
let stats = await file.getStats();
|
|
2049
2050
|
options.cache_time = stats.mtime;
|
|
2050
2051
|
}
|
|
2051
2052
|
|
|
2053
|
+
if (options.content_length == null) {
|
|
2054
|
+
options.content_length = stats.size;
|
|
2055
|
+
}
|
|
2056
|
+
|
|
2052
2057
|
if (!options.mimetype) {
|
|
2053
2058
|
options.mimetype = await file.getMimetype();
|
|
2054
2059
|
}
|
|
@@ -2121,7 +2126,7 @@ Conduit.setTypedMethod([Types.Stream, Types.Object.optional()], function serveFi
|
|
|
2121
2126
|
*
|
|
2122
2127
|
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
2123
2128
|
* @since 1.3.0
|
|
2124
|
-
* @version 1.3.
|
|
2129
|
+
* @version 1.3.13
|
|
2125
2130
|
*
|
|
2126
2131
|
* @param {Stream} stream The stream to send
|
|
2127
2132
|
* @param {Object} options Options, including headers
|
|
@@ -2177,6 +2182,11 @@ Conduit.setMethod(function _sendStream(stream, options) {
|
|
|
2177
2182
|
this.setHeader('content-disposition', disposition);
|
|
2178
2183
|
}
|
|
2179
2184
|
|
|
2185
|
+
// Set the content-length response header when not compressing
|
|
2186
|
+
if (!options.compress && options.content_length != null) {
|
|
2187
|
+
this.setHeader('content-length', options.content_length);
|
|
2188
|
+
}
|
|
2189
|
+
|
|
2180
2190
|
// Set all the headers
|
|
2181
2191
|
for (key in options.headers) {
|
|
2182
2192
|
this.setHeader(key, options.headers[key]);
|
package/lib/class/controller.js
CHANGED
|
File without changes
|
package/lib/class/datasource.js
CHANGED
|
File without changes
|
package/lib/class/document.js
CHANGED
|
File without changes
|
|
File without changes
|
package/lib/class/element.js
CHANGED
|
File without changes
|
package/lib/class/error.js
CHANGED
|
File without changes
|
package/lib/class/field.js
CHANGED
|
File without changes
|
package/lib/class/field_value.js
CHANGED
|
File without changes
|
package/lib/class/helper.js
CHANGED
|
File without changes
|
package/lib/class/inode.js
CHANGED
|
File without changes
|
package/lib/class/inode_dir.js
CHANGED
|
File without changes
|
package/lib/class/inode_file.js
CHANGED
|
File without changes
|
package/lib/class/inode_list.js
CHANGED
|
File without changes
|
package/lib/class/migration.js
CHANGED
|
File without changes
|
package/lib/class/model.js
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -111,7 +111,7 @@ PathParamDefinition.enforceProperty(function model_constructor(new_value) {
|
|
|
111
111
|
*
|
|
112
112
|
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
113
113
|
* @since 1.3.0
|
|
114
|
-
* @version 1.3.
|
|
114
|
+
* @version 1.3.12
|
|
115
115
|
*/
|
|
116
116
|
PathParamDefinition.setMethod(function parseTypeDefinition() {
|
|
117
117
|
|
|
@@ -142,7 +142,7 @@ PathParamDefinition.setMethod(function parseTypeDefinition() {
|
|
|
142
142
|
current = class_path;
|
|
143
143
|
|
|
144
144
|
for (let piece of this.typedef) {
|
|
145
|
-
if (piece[0] != piece[0].toUpperCase()) {
|
|
145
|
+
if (piece[0] != piece[0].toUpperCase() || !String.isLetter(piece[0])) {
|
|
146
146
|
current = field_path;
|
|
147
147
|
}
|
|
148
148
|
|
|
File without changes
|
package/lib/class/reciprocal.js
CHANGED
|
File without changes
|
package/lib/class/route.js
CHANGED
|
File without changes
|
package/lib/class/router.js
CHANGED
|
File without changes
|
package/lib/class/schema.js
CHANGED
|
File without changes
|
|
File without changes
|
package/lib/class/session.js
CHANGED
|
File without changes
|
|
File without changes
|
package/lib/class/sitemap.js
CHANGED
|
File without changes
|
package/lib/class/task.js
CHANGED
|
File without changes
|
package/lib/core/base.js
CHANGED
|
File without changes
|
|
@@ -364,6 +364,63 @@ Alchemy.setMethod(function getValidatorClass(name) {
|
|
|
364
364
|
}
|
|
365
365
|
});
|
|
366
366
|
|
|
367
|
+
/**
|
|
368
|
+
* Get the display title of something
|
|
369
|
+
*
|
|
370
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
371
|
+
* @since 1.3.13
|
|
372
|
+
* @version 1.3.14
|
|
373
|
+
*
|
|
374
|
+
* @param {Object} value
|
|
375
|
+
*
|
|
376
|
+
* @return {String}
|
|
377
|
+
*/
|
|
378
|
+
Alchemy.setMethod(function getDisplayTitle(value, max_length) {
|
|
379
|
+
|
|
380
|
+
//.title || value.name || value.slug || value.$pk || value._id || value.id
|
|
381
|
+
|
|
382
|
+
if (!value || Object.isPrimitive(value)) {
|
|
383
|
+
|
|
384
|
+
if (max_length == null) {
|
|
385
|
+
max_length = 48;
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
let result = '' + value;
|
|
389
|
+
|
|
390
|
+
if (result.length > max_length) {
|
|
391
|
+
result = result.truncate(max_length - 2);
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
return result;
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
let type = typeof value;
|
|
398
|
+
|
|
399
|
+
if (type == 'symbol') {
|
|
400
|
+
return value.toString();
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
let result;
|
|
404
|
+
|
|
405
|
+
// `getDisplayTitle` might already return the ID as a fallback,
|
|
406
|
+
// so we prefer `getDisplayTitleOrNull`
|
|
407
|
+
if (typeof value.getDisplayTitleOrNull == 'function') {
|
|
408
|
+
result = value.getDisplayTitleOrNull();
|
|
409
|
+
} else if (typeof value.getDisplayTitle == 'function') {
|
|
410
|
+
result = value.getDisplayTitle();
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
if (result == null || result === '') {
|
|
414
|
+
result = value.title || value.name || value.label || value.slug || value.id || value.$pk || value._id;
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
if (max_length != null && typeof result == 'string' && result.length > max_length) {
|
|
418
|
+
result = result.truncate(max_length - 2);
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
return result || '';
|
|
422
|
+
});
|
|
423
|
+
|
|
367
424
|
/**
|
|
368
425
|
* Pick a translation
|
|
369
426
|
*
|
package/lib/core/client_base.js
CHANGED
|
File without changes
|
package/lib/core/discovery.js
CHANGED
|
File without changes
|
package/lib/core/middleware.js
CHANGED
|
File without changes
|
package/lib/core/routing.js
CHANGED
|
File without changes
|
package/lib/core/socket.js
CHANGED
|
File without changes
|
package/lib/init/alchemy.js
CHANGED
|
File without changes
|
package/lib/init/constants.js
CHANGED
|
File without changes
|
package/lib/init/devwatch.js
CHANGED
|
File without changes
|
package/lib/init/functions.js
CHANGED
|
File without changes
|
|
File without changes
|
package/lib/init/requirements.js
CHANGED
|
File without changes
|
package/lib/stages.js
CHANGED
|
File without changes
|