Make browse action available for dynamic/JS-driven tokenizers

Summary: Ref T5750. This makes browse work for all of the dynamic tokenizers in Herald, Policies, batch editor, etc.

Test Plan: Used tokenizers in Herald, Policies, Batch editor.

Reviewers: chad, btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T5750

Differential Revision: https://secure.phabricator.com/D12442
This commit is contained in:
epriestley
2015-04-16 14:46:10 -07:00
parent a641601407
commit a4261f41c2
14 changed files with 95 additions and 78 deletions

View File

@@ -109,7 +109,15 @@ a.jx-tokenizer-token:hover {
width: 100%;
}
.jx-tokenizer-frame-input {
.jx-tokenizer-frame .jx-tokenizer-frame-browse {
display: none;
}
.has-browse .jx-tokenizer-frame-browse {
display: table-cell;
}
.jx-tokenizer-frame td.jx-tokenizer-frame-input {
width: 100%;
}

View File

@@ -85,6 +85,7 @@ JX.install('Tokenizer', {
}
if (this._frame) {
JX.DOM.alterClass(this._frame, 'has-browse', !!this.getBrowseURI());
JX.DOM.listen(
this._frame,
'click',

View File

@@ -277,25 +277,21 @@ JX.install('HeraldRuleEditor', {
},
_newTokenizer : function(type) {
var template = JX.$N(
'div',
JX.$H(this._config.template.markup));
template = template.firstChild;
template.id = '';
var tokenizerConfig = {
root : template,
src : this._config.template.source[type].uri,
placeholder: this._config.template.source[type].placeholder,
browseURI: this._config.template.source[type].browseURI,
icons : this._config.template.icons,
username : this._config.username
};
var build = JX.Prefab.buildTokenizer(tokenizerConfig);
var build = JX.Prefab.newTokenizerFromTemplate(
this._config.template.markup,
tokenizerConfig);
build.tokenizer.start();
return [
template,
build.node,
function() {
return build.tokenizer.getTokens();
},

View File

@@ -136,18 +136,14 @@ JX.behavior('maniphest-batch-editor', function(config) {
});
function build_tokenizer(tconfig) {
var template = JX.$N('div', JX.$H(config.tokenizerTemplate)).firstChild;
template.id = '';
var build_config = JX.copy({}, tconfig);
build_config.root = template;
var built = JX.Prefab.buildTokenizer(build_config);
var built = JX.Prefab.newTokenizerFromTemplate(
config.tokenizerTemplate,
JX.copy({}, tconfig));
built.tokenizer.start();
return {
object: built.tokenizer,
template: template
template: built.node
};
}

View File

@@ -118,17 +118,20 @@ JX.behavior('policy-rule-editor', function(config) {
switch (type) {
case 'tokenizer':
node = JX.$H(template.markup).getNode();
node.id = '';
var options = {
root: node,
src: template.uri,
placeholder: template.placeholder,
browseURI: template.browseURI,
limit: template.limit
};
var tokenizer = JX.Prefab.buildTokenizer(options).tokenizer;
var build = JX.Prefab.newTokenizerFromTemplate(
template.markup,
options);
node = build.node;
var tokenizer = build.tokenizer;
tokenizer.start();
get_fn = function() { return JX.keys(tokenizer.getTokens()); };

View File

@@ -31,6 +31,17 @@ JX.install('Prefab', {
return select;
},
newTokenizerFromTemplate: function(markup, config) {
var template = JX.$H(markup).getFragment().firstChild;
var container = JX.DOM.find(template, 'div', 'tokenizer-container');
container.id = '';
config.root = container;
var build = JX.Prefab.buildTokenizer(config);
build.node = template;
return build;
},
/**
* Build a Phabricator tokenizer out of a configuration with application