Initial commit
This commit is contained in:
25
lib/assets/javascripts/builder/editor/editor-hints/css-hints.js
Executable file
25
lib/assets/javascripts/builder/editor/editor-hints/css-hints.js
Executable file
@@ -0,0 +1,25 @@
|
||||
module.exports = [{
|
||||
keywords: 'buffer-size',
|
||||
type: 'Map'
|
||||
}, {
|
||||
keywords: 'marker-fill marker-width marker-fill-opacity marker-opacity marker-line-color marker-line-width marker-line-opacity marker-comp-op marker-allow-overlap marker-file marker-type marker-height marker-width marker-transform marker-placement marker-ignore-placement marker-spacing marker-avoid-edges point-file point-opacity point-comp-op point-allow-overlap point-placement point-ignore-placement point-transform',
|
||||
type: 'Points'
|
||||
}, {
|
||||
keywords: 'line-color line-width line-opacity line-comp-op line-pattern-file line-join line-cap line-dasharray line-dash-offset line-offset line-simplify line-simplify-algorithm line-smooth line-clip',
|
||||
type: 'Lines'
|
||||
}, {
|
||||
keywords: 'polygon-fill polygon-opacity polygon-comp-op polygon-pattern-file polygon-pattern-alignment polygon-pattern-opacity polygon-smooth polygon-simplify polygon-simplify-algorithm polygon-gamma polygon-gamma-method polygon-geometry-transform polygon-clip',
|
||||
type: 'Polygons'
|
||||
}, {
|
||||
keywords: 'text-name text-face-name text-size text-fill text-opacity text-comp-op text-halo-radius text-halo-fill text-halo-rasterizer text-allow-overlap text-transform text-placement text-placement-type text-dx text-dy text-wrap-width text-wrap-before text-character-spacing text-line-spacing text-min-distance text-avoid-edges text-orientation text-vertical-alignment',
|
||||
type: 'Text'
|
||||
}, {
|
||||
keywords: 'building-fill building-fill-opacity building-height',
|
||||
type: 'Building'
|
||||
}, {
|
||||
keywords: 'shield-name shield-face-name shield-size shield-file shield-fill shield-opacity shield-text-opacity shield-allow-overlap shield-placements shield-placement-type shield-dy shield-dx shield-text-dx shield-text-dy shield-min-distance shield-avoid-edges',
|
||||
type: 'Shield'
|
||||
}, {
|
||||
keywords: 'image-filters comp-op opacity',
|
||||
type: ''
|
||||
}];
|
||||
96
lib/assets/javascripts/builder/editor/editor-hints/factory-hints.js
Executable file
96
lib/assets/javascripts/builder/editor/editor-hints/factory-hints.js
Executable file
@@ -0,0 +1,96 @@
|
||||
var _ = require('underscore');
|
||||
var TableNameUtils = require('builder/helpers/table-name-utils');
|
||||
|
||||
var memo = {};
|
||||
|
||||
var OPTIONAL_OPTS = [
|
||||
'querySchemaModel',
|
||||
'layerDefinitionModel',
|
||||
'tokens'
|
||||
];
|
||||
|
||||
var defaults = {
|
||||
tableName: true,
|
||||
columnsName: true,
|
||||
keywords: true
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
init: function (opts) {
|
||||
if (!opts) throw new Error('options are required for hints');
|
||||
|
||||
this.options = _.defaults(
|
||||
_.pick(opts, ['tableName', 'columnsName', 'keywords'])
|
||||
, defaults
|
||||
);
|
||||
|
||||
_.each(OPTIONAL_OPTS, function (item) {
|
||||
this['_' + item] = opts[item];
|
||||
}, this);
|
||||
},
|
||||
|
||||
hints: function () {
|
||||
// array of objects {text, type}
|
||||
return this.hints;
|
||||
},
|
||||
|
||||
reset: function () {
|
||||
this.hints = _.union(this._getTableName(), this._getColumns(), this._getKeywords());
|
||||
return this;
|
||||
},
|
||||
|
||||
_getKeywords: function () {
|
||||
if (this.options.keywords) {
|
||||
return this._tokens && this._memo(this._tokens);
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
},
|
||||
|
||||
_getColumns: function () {
|
||||
if (!this.options.columnsName) {
|
||||
return [];
|
||||
}
|
||||
|
||||
var columns = this._querySchemaModel.columnsCollection;
|
||||
return columns.map(function (mdl) {
|
||||
var columnName = mdl.get('name');
|
||||
return {
|
||||
text: columnName,
|
||||
type: 'Column_name'
|
||||
};
|
||||
});
|
||||
},
|
||||
|
||||
_getTableName: function () {
|
||||
if (!this.options.tableName) {
|
||||
return [];
|
||||
}
|
||||
|
||||
var tableName = this._layerDefinitionModel.getTableName();
|
||||
tableName = TableNameUtils.getUnqualifiedName(tableName);
|
||||
return [{
|
||||
text: tableName,
|
||||
type: 'Table_name'
|
||||
}];
|
||||
},
|
||||
|
||||
_memo: function (str, type) {
|
||||
if (str in memo) {
|
||||
return memo[str];
|
||||
} else {
|
||||
return (memo[str] = this._make(str, type));
|
||||
}
|
||||
},
|
||||
|
||||
_make: function (str, type) {
|
||||
return _.chain(str).map(function (set) {
|
||||
return set.keywords.split(' ').map(function (item) {
|
||||
return {
|
||||
text: item,
|
||||
type: set.type
|
||||
};
|
||||
});
|
||||
}).flatten().value();
|
||||
}
|
||||
};
|
||||
7
lib/assets/javascripts/builder/editor/editor-hints/sql-hints.js
Executable file
7
lib/assets/javascripts/builder/editor/editor-hints/sql-hints.js
Executable file
@@ -0,0 +1,7 @@
|
||||
module.exports = [{
|
||||
keywords: 'alter and as asc between by count create delete desc distinct drop from group having in insert into is join like not on or order select set table union update values where limit',
|
||||
type: 'Sql'
|
||||
}, {
|
||||
keywords: 'ST_GeometryType ST_polygon ST_multipolygon ST_multilinestring ST_linestring ST_multipoint ST_point',
|
||||
type: 'Postgis'
|
||||
}];
|
||||
Reference in New Issue
Block a user