1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-09-19 16:58:48 +02:00

Some herald improvements.

This commit is contained in:
epriestley 2011-03-22 20:41:02 -07:00
parent 3c0a822d65
commit deb12c9fe8
11 changed files with 160 additions and 59 deletions

View file

@ -101,8 +101,6 @@ foreach ($file_map as $path => $info) {
$provides = array_filter($provides);
$requires = array_filter($requires);
var_dump($requires);
if (count($provides) !== 1) {
throw new Exception(
"File {$path} must @provide exactly one Celerity target.");

View file

@ -418,21 +418,24 @@ celerity_register_resource_map(array(
),
'javelin-behavior-herald-rule-editor' =>
array(
'uri' => '/res/f18bcd5e/rsrc/js/application/herald/herald-rule-editor.js',
'uri' => '/res/48108130/rsrc/js/application/herald/herald-rule-editor.js',
'type' => 'js',
'requires' =>
array(
0 => 'herald-rule-editor',
1 => 'javelin-lib-dev',
),
'disk' => '/rsrc/js/application/herald/herald-rule-editor.js',
),
'herald-rule-editor' =>
array(
'uri' => '/res/e71d1d0e/rsrc/js/application/herald/HeraldRuleEditor.js',
'uri' => '/res/8b5e9d5e/rsrc/js/application/herald/HeraldRuleEditor.js',
'type' => 'js',
'requires' =>
array(
0 => 'multirow-row-manager',
1 => 'javelin-lib-dev',
2 => 'javelin-typeahead-dev',
),
'disk' => '/rsrc/js/application/herald/HeraldRuleEditor.js',
),

View file

@ -57,6 +57,7 @@ phutil_register_library_map(array(
'AphrontResponse' => 'aphront/response/base',
'AphrontSideNavView' => 'view/layout/sidenav',
'AphrontTableView' => 'view/control/table',
'AphrontTokenizerTemplateView' => 'view/control/tokenizer',
'AphrontURIMapper' => 'aphront/mapper',
'AphrontView' => 'view/base',
'AphrontWebpageResponse' => 'aphront/response/webpage',
@ -449,6 +450,7 @@ phutil_register_library_map(array(
'AphrontRequestFailureView' => 'AphrontView',
'AphrontSideNavView' => 'AphrontView',
'AphrontTableView' => 'AphrontView',
'AphrontTokenizerTemplateView' => 'AphrontView',
'AphrontWebpageResponse' => 'AphrontResponse',
'CelerityResourceController' => 'AphrontController',
'ConduitAPI_conduit_connect_Method' => 'ConduitAPIMethod',

View file

@ -276,7 +276,8 @@ class HeraldRuleController extends HeraldController {
array(
'href' => '#',
'class' => 'button green',
'sigil' => 'create-action',
'sigil' => 'create-condition',
'mustcapture' => true,
),
'Create New Condition').
'<p>When '.$must_match.' these conditions are met:</p>'.
@ -290,7 +291,15 @@ class HeraldRuleController extends HeraldController {
->appendChild(
'<h1>Action</h1>'.
'<div style="margin: .5em 0 1em; padding: .5em; background: #aaa;">'.
'<a href="#" class="button green">Create New Action</a>'.
javelin_render_tag(
'a',
array(
'href' => '#',
'class' => 'button green',
'sigil' => 'create-action',
'mustcapture' => true,
),
'Create New Action').
'<p>Take these actions:</p>'.
javelin_render_tag(
'table',
@ -301,7 +310,7 @@ class HeraldRuleController extends HeraldController {
'</div>')
->appendChild(
id(new AphrontFormSubmitControl())
->setValue('Save')
->setValue('Save Rule')
->addCancelButton('/herald/view/'.$rule->getContentType().'/'));
/*
$form =
@ -482,15 +491,20 @@ class HeraldRuleController extends HeraldController {
}
protected function buildTokenizerTemplates() {
$template = new AphrontTokenizerTemplateView();
$template = $template->render();
return array(
'source' => array(
'email' => '/datasource/mailable/',
'user' => '/datasource/user/',
'repository' => '/datasource/repository/',
'email' => '/typeahead/common/mailable/',
'user' => '/typeahead/common/user/',
'repository' => '/typeahead/common/repository/',
/*
'tag' => '/datasource/tag/',
'package' => '/datasource/package/',
*/
),
'markup' => 'derp derp',//id(<javelin:tokenizer-template />)->toString(),
'markup' => $template,
);
}
}

View file

@ -19,6 +19,7 @@ phutil_require_module('phabricator', 'applications/herald/storage/condition');
phutil_require_module('phabricator', 'applications/herald/storage/rule');
phutil_require_module('phabricator', 'applications/phid/handle/data');
phutil_require_module('phabricator', 'infrastructure/javelin/api');
phutil_require_module('phabricator', 'view/control/tokenizer');
phutil_require_module('phabricator', 'view/form/base');
phutil_require_module('phabricator', 'view/form/control/submit');
phutil_require_module('phabricator', 'view/layout/panel');

View file

@ -0,0 +1,104 @@
<?php
/*
* Copyright 2011 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
class AphrontTokenizerTemplateView extends AphrontView {
private $value;
private $name;
private $id;
public function setID($id) {
$this->id = $id;
return $this;
}
public function setValue(array $value) {
$this->value = $value;
return $this;
}
public function getValue() {
return $this->value;
}
public function setName($name) {
$this->name = $name;
return $this;
}
public function getName() {
return $this->name;
}
public function render() {
require_celerity_resource('aphront-tokenizer-control-css');
$id = $this->id;
$name = $this->getName();
$values = nonempty($this->getValue(), array());
$tokens = array();
foreach ($values as $key => $value) {
$tokens[] = $this->renderToken($key, $value);
}
$input = javelin_render_tag(
'input',
array(
'mustcapture' => true,
'name' => $name,
'class' => 'jx-tokenizer-input',
'sigil' => 'tokenizer',
'style' => 'width: 0px;',
'disabled' => 'disabled',
'type' => 'text',
));
return phutil_render_tag(
'div',
array(
'id' => $id,
'class' => 'jx-tokenizer-container',
),
implode('', $tokens).
$input.
'<div style="clear: both;"></div>');
}
private function renderToken($key, $value) {
$input_name = $this->getName();
if ($input_name) {
$input_name .= '[]';
}
return phutil_render_tag(
'a',
array(
'class' => 'jx-tokenizer-token',
),
phutil_escape_html($value).
phutil_render_tag(
'input',
array(
'type' => 'hidden',
'name' => $input_name,
'value' => $key,
)).
'<span class="jx-tokenizer-x-placeholder"></span>');
}
}

View file

@ -0,0 +1,17 @@
<?php
/**
* This file is automatically generated. Lint this module to rebuild it.
* @generated
*/
phutil_require_module('phabricator', 'infrastructure/celerity/api');
phutil_require_module('phabricator', 'infrastructure/javelin/markup');
phutil_require_module('phabricator', 'view/base');
phutil_require_module('phutil', 'markup');
phutil_require_module('phutil', 'utils');
phutil_require_source('AphrontTokenizerTemplateView.php');

View file

@ -42,16 +42,10 @@ class AphrontFormTokenizerControl extends AphrontFormControl {
}
protected function renderInput() {
require_celerity_resource('aphront-tokenizer-control-css');
require_celerity_resource('javelin-typeahead-dev');
$tokens = array();
$values = nonempty($this->getValue(), array());
foreach ($values as $key => $value) {
$tokens[] = $this->renderToken($key, $value);
}
$name = $this->getName();
$values = nonempty($this->getValue(), array());
$input = javelin_render_tag(
'input',
@ -71,6 +65,11 @@ class AphrontFormTokenizerControl extends AphrontFormControl {
$id = celerity_generate_unique_node_id();
}
$template = new AphrontTokenizerTemplateView();
$template->setName($name);
$template->setID($id);
$template->setValue($values);
if (!$this->disableBehavior) {
Javelin::initBehavior('aphront-basic-tokenizer', array(
'id' => $id,
@ -80,44 +79,7 @@ class AphrontFormTokenizerControl extends AphrontFormControl {
));
}
return phutil_render_tag(
'div',
array(
'id' => $id,
'class' => 'jx-tokenizer-container',
),
implode('', $tokens).
$input.
'<div style="clear: both;"></div>');
return phutil_render_tag(
'input',
array(
'type' => 'text',
'name' => $this->getName(),
'disabled' => $this->getDisabled() ? 'disabled' : null,
));
}
private function renderToken($key, $value) {
$input_name = $this->getName();
if ($input_name) {
$input_name .= '[]';
}
return phutil_render_tag(
'a',
array(
'class' => 'jx-tokenizer-token',
),
phutil_escape_html($value).
phutil_render_tag(
'input',
array(
'type' => 'hidden',
'name' => $input_name,
'value' => $key,
)).
'<span class="jx-tokenizer-x-placeholder"></span>');
return $template->render();
}

View file

@ -9,9 +9,9 @@
phutil_require_module('phabricator', 'infrastructure/celerity/api');
phutil_require_module('phabricator', 'infrastructure/javelin/api');
phutil_require_module('phabricator', 'infrastructure/javelin/markup');
phutil_require_module('phabricator', 'view/control/tokenizer');
phutil_require_module('phabricator', 'view/form/control/base');
phutil_require_module('phutil', 'markup');
phutil_require_module('phutil', 'utils');

View file

@ -205,7 +205,7 @@ JX.install('HeraldRuleEditor', {
set_fn = function(v) { input.value = v; };
break;
case 'email':
case 'employee':
case 'user':
case 'repository':
case 'tag':
case 'package':

View file

@ -1,6 +1,6 @@
/**
* @requires herald-rule-editor
* javelin-behavior
* javelin-lib-dev
* @provides javelin-behavior-herald-rule-editor
* @javelin
*/