diff --git a/src/__celerity_resource_map__.php b/src/__celerity_resource_map__.php index e598b6a8f2..82db3b9238 100644 --- a/src/__celerity_resource_map__.php +++ b/src/__celerity_resource_map__.php @@ -669,7 +669,7 @@ celerity_register_resource_map(array( ), 'aphront-form-view-css' => array( - 'uri' => '/res/ec323d34/rsrc/css/aphront/form-view.css', + 'uri' => '/res/c1cf5cce/rsrc/css/aphront/form-view.css', 'type' => 'css', 'requires' => array( @@ -805,7 +805,7 @@ celerity_register_resource_map(array( ), 'conpherence-widget-pane-css' => array( - 'uri' => '/res/6e5755bb/rsrc/css/application/conpherence/widget-pane.css', + 'uri' => '/res/e67ad581/rsrc/css/application/conpherence/widget-pane.css', 'type' => 'css', 'requires' => array( @@ -1167,28 +1167,30 @@ celerity_register_resource_map(array( ), 'javelin-behavior-conpherence-menu' => array( - 'uri' => '/res/0ad6ab54/rsrc/js/application/conpherence/behavior-menu.js', - 'type' => 'js', - 'requires' => - array( - 0 => 'javelin-behavior', - 1 => 'javelin-dom', - 2 => 'javelin-workflow', - 3 => 'javelin-util', - 4 => 'javelin-stratcom', - 5 => 'javelin-uri', - ), - 'disk' => '/rsrc/js/application/conpherence/behavior-menu.js', - ), - 'javelin-behavior-conpherence-pontificate' => - array( - 'uri' => '/res/06214a06/rsrc/js/application/conpherence/behavior-pontificate.js', + 'uri' => '/res/cb1a5cf0/rsrc/js/application/conpherence/behavior-menu.js', 'type' => 'js', 'requires' => array( 0 => 'javelin-behavior', 1 => 'javelin-dom', 2 => 'javelin-request', + 3 => 'javelin-stratcom', + 4 => 'javelin-uri', + 5 => 'javelin-util', + 6 => 'javelin-workflow', + ), + 'disk' => '/rsrc/js/application/conpherence/behavior-menu.js', + ), + 'javelin-behavior-conpherence-pontificate' => + array( + 'uri' => '/res/15263692/rsrc/js/application/conpherence/behavior-pontificate.js', + 'type' => 'js', + 'requires' => + array( + 0 => 'javelin-behavior', + 1 => 'javelin-dom', + 2 => 'javelin-util', + 3 => 'javelin-workflow', ), 'disk' => '/rsrc/js/application/conpherence/behavior-pontificate.js', ), @@ -1933,7 +1935,7 @@ celerity_register_resource_map(array( ), 'javelin-behavior-pholio-mock-view' => array( - 'uri' => '/res/10573d54/rsrc/js/application/pholio/behavior-pholio-mock-view.js', + 'uri' => '/res/bee3cef2/rsrc/js/application/pholio/behavior-pholio-mock-view.js', 'type' => 'js', 'requires' => array( @@ -3500,7 +3502,7 @@ celerity_register_resource_map(array( ), array( 'packages' => array( - '6beef3e5' => + '8e2735e2' => array( 'name' => 'core.pkg.css', 'symbols' => @@ -3543,7 +3545,7 @@ celerity_register_resource_map(array( 35 => 'phabricator-object-item-list-view-css', 36 => 'global-drag-and-drop-css', ), - 'uri' => '/res/pkg/6beef3e5/core.pkg.css', + 'uri' => '/res/pkg/8e2735e2/core.pkg.css', 'type' => 'css', ), 'f24c209c' => @@ -3733,17 +3735,17 @@ celerity_register_resource_map(array( 'reverse' => array( 'aphront-attached-file-view-css' => 'eb35a026', - 'aphront-crumbs-view-css' => '6beef3e5', - 'aphront-dialog-view-css' => '6beef3e5', - 'aphront-error-view-css' => '6beef3e5', - 'aphront-form-view-css' => '6beef3e5', - 'aphront-list-filter-view-css' => '6beef3e5', - 'aphront-pager-view-css' => '6beef3e5', - 'aphront-panel-view-css' => '6beef3e5', - 'aphront-table-view-css' => '6beef3e5', - 'aphront-tokenizer-control-css' => '6beef3e5', - 'aphront-tooltip-css' => '6beef3e5', - 'aphront-typeahead-control-css' => '6beef3e5', + 'aphront-crumbs-view-css' => '8e2735e2', + 'aphront-dialog-view-css' => '8e2735e2', + 'aphront-error-view-css' => '8e2735e2', + 'aphront-form-view-css' => '8e2735e2', + 'aphront-list-filter-view-css' => '8e2735e2', + 'aphront-pager-view-css' => '8e2735e2', + 'aphront-panel-view-css' => '8e2735e2', + 'aphront-table-view-css' => '8e2735e2', + 'aphront-tokenizer-control-css' => '8e2735e2', + 'aphront-tooltip-css' => '8e2735e2', + 'aphront-typeahead-control-css' => '8e2735e2', 'differential-changeset-view-css' => '8aaacd1b', 'differential-core-view-css' => '8aaacd1b', 'differential-inline-comment-editor' => '322728f3', @@ -3757,7 +3759,7 @@ celerity_register_resource_map(array( 'differential-table-of-contents-css' => '8aaacd1b', 'diffusion-commit-view-css' => 'c8ce2d88', 'diffusion-icons-css' => 'c8ce2d88', - 'global-drag-and-drop-css' => '6beef3e5', + 'global-drag-and-drop-css' => '8e2735e2', 'inline-comment-summary-css' => '8aaacd1b', 'javelin-aphlict' => 'f24c209c', 'javelin-behavior' => 'cd1d650a', @@ -3828,48 +3830,48 @@ celerity_register_resource_map(array( 'javelin-util' => 'cd1d650a', 'javelin-vector' => 'cd1d650a', 'javelin-workflow' => 'cd1d650a', - 'lightbox-attachment-css' => '6beef3e5', + 'lightbox-attachment-css' => '8e2735e2', 'maniphest-task-summary-css' => 'eb35a026', 'maniphest-transaction-detail-css' => 'eb35a026', 'phabricator-busy' => 'f24c209c', 'phabricator-content-source-view-css' => '8aaacd1b', - 'phabricator-core-buttons-css' => '6beef3e5', - 'phabricator-core-css' => '6beef3e5', - 'phabricator-crumbs-view-css' => '6beef3e5', - 'phabricator-directory-css' => '6beef3e5', + 'phabricator-core-buttons-css' => '8e2735e2', + 'phabricator-core-css' => '8e2735e2', + 'phabricator-crumbs-view-css' => '8e2735e2', + 'phabricator-directory-css' => '8e2735e2', 'phabricator-drag-and-drop-file-upload' => '322728f3', 'phabricator-dropdown-menu' => 'f24c209c', 'phabricator-file-upload' => 'f24c209c', - 'phabricator-filetree-view-css' => '6beef3e5', - 'phabricator-flag-css' => '6beef3e5', - 'phabricator-form-view-css' => '6beef3e5', - 'phabricator-header-view-css' => '6beef3e5', - 'phabricator-jump-nav' => '6beef3e5', + 'phabricator-filetree-view-css' => '8e2735e2', + 'phabricator-flag-css' => '8e2735e2', + 'phabricator-form-view-css' => '8e2735e2', + 'phabricator-header-view-css' => '8e2735e2', + 'phabricator-jump-nav' => '8e2735e2', 'phabricator-keyboard-shortcut' => 'f24c209c', 'phabricator-keyboard-shortcut-manager' => 'f24c209c', - 'phabricator-main-menu-view' => '6beef3e5', + 'phabricator-main-menu-view' => '8e2735e2', 'phabricator-menu-item' => 'f24c209c', - 'phabricator-nav-view-css' => '6beef3e5', + 'phabricator-nav-view-css' => '8e2735e2', 'phabricator-notification' => 'f24c209c', - 'phabricator-notification-css' => '6beef3e5', - 'phabricator-notification-menu-css' => '6beef3e5', - 'phabricator-object-item-list-view-css' => '6beef3e5', + 'phabricator-notification-css' => '8e2735e2', + 'phabricator-notification-menu-css' => '8e2735e2', + 'phabricator-object-item-list-view-css' => '8e2735e2', 'phabricator-object-selector-css' => '8aaacd1b', 'phabricator-paste-file-upload' => 'f24c209c', 'phabricator-prefab' => 'f24c209c', 'phabricator-project-tag-css' => 'eb35a026', - 'phabricator-remarkup-css' => '6beef3e5', + 'phabricator-remarkup-css' => '8e2735e2', 'phabricator-shaped-request' => '322728f3', - 'phabricator-side-menu-view-css' => '6beef3e5', - 'phabricator-standard-page-view' => '6beef3e5', + 'phabricator-side-menu-view-css' => '8e2735e2', + 'phabricator-standard-page-view' => '8e2735e2', 'phabricator-textareautils' => 'f24c209c', 'phabricator-tooltip' => 'f24c209c', - 'phabricator-transaction-view-css' => '6beef3e5', - 'phabricator-zindex-css' => '6beef3e5', - 'sprite-apps-large-css' => '6beef3e5', - 'sprite-gradient-css' => '6beef3e5', - 'sprite-icon-css' => '6beef3e5', - 'sprite-menu-css' => '6beef3e5', - 'syntax-highlighting-css' => '6beef3e5', + 'phabricator-transaction-view-css' => '8e2735e2', + 'phabricator-zindex-css' => '8e2735e2', + 'sprite-apps-large-css' => '8e2735e2', + 'sprite-gradient-css' => '8e2735e2', + 'sprite-icon-css' => '8e2735e2', + 'sprite-menu-css' => '8e2735e2', + 'syntax-highlighting-css' => '8e2735e2', ), )); diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index 8d3618dad4..c24478afa1 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -208,6 +208,7 @@ phutil_register_library_map(array( 'ConpherenceController' => 'applications/conpherence/controller/ConpherenceController.php', 'ConpherenceDAO' => 'applications/conpherence/storage/ConpherenceDAO.php', 'ConpherenceEditor' => 'applications/conpherence/editor/ConpherenceEditor.php', + 'ConpherenceFileWidgetView' => 'applications/conpherence/view/ConpherenceFileWidgetView.php', 'ConpherenceFormDragAndDropUploadControl' => 'applications/conpherence/view/ConpherenceFormDragAndDropUploadControl.php', 'ConpherenceImageData' => 'applications/conpherence/constants/ConpherenceImageData.php', 'ConpherenceListController' => 'applications/conpherence/controller/ConpherenceListController.php', @@ -1759,6 +1760,7 @@ phutil_register_library_map(array( 'ConpherenceController' => 'PhabricatorController', 'ConpherenceDAO' => 'PhabricatorLiskDAO', 'ConpherenceEditor' => 'PhabricatorApplicationTransactionEditor', + 'ConpherenceFileWidgetView' => 'AphrontView', 'ConpherenceFormDragAndDropUploadControl' => 'AphrontFormControl', 'ConpherenceImageData' => 'ConpherenceConstants', 'ConpherenceListController' => 'ConpherenceController', diff --git a/src/applications/conpherence/controller/ConpherenceController.php b/src/applications/conpherence/controller/ConpherenceController.php index 770004903b..9ff05a7dde 100644 --- a/src/applications/conpherence/controller/ConpherenceController.php +++ b/src/applications/conpherence/controller/ConpherenceController.php @@ -241,7 +241,10 @@ abstract class ConpherenceController extends PhabricatorController { array( 'class' => 'edit', 'href' => $edit_href, - 'sigil' => 'workflow edit-action', + 'sigil' => 'conpherence-edit-metadata', + 'meta' => array( + 'action' => 'metadata' + ) ), ''). phutil_tag( @@ -340,6 +343,7 @@ abstract class ConpherenceController extends PhabricatorController { 'header' => 'conpherence-header-pane', 'menu_pane' => 'conpherence-menu', 'form_pane' => 'conpherence-form', + 'file_widget' => 'widgets-files', )); } } diff --git a/src/applications/conpherence/controller/ConpherenceUpdateController.php b/src/applications/conpherence/controller/ConpherenceUpdateController.php index 445d2b6013..ca2a07fbf1 100644 --- a/src/applications/conpherence/controller/ConpherenceUpdateController.php +++ b/src/applications/conpherence/controller/ConpherenceUpdateController.php @@ -35,7 +35,9 @@ final class ConpherenceUpdateController extends ->executeOne(); $supported_formats = PhabricatorFile::getTransformableImageFormats(); + $action = $request->getStr('action', 'metadata'); $latest_transaction_id = null; + $fancy_ajax_style = true; $error_view = null; $e_file = array(); $errors = array(); @@ -50,7 +52,6 @@ final class ConpherenceUpdateController extends ->setContentSource($content_source) ->setActor($user); - $action = $request->getStr('action'); switch ($action) { case 'message': $message = $request->getStr('text'); @@ -65,6 +66,7 @@ final class ConpherenceUpdateController extends $left = $request->getInt('image_x'); $file_id = $request->getInt('file_id'); $title = $request->getStr('title'); + $updated = false; if ($file_id) { $orig_file = id(new PhabricatorFileQuery()) ->setViewer($user) @@ -101,6 +103,8 @@ final class ConpherenceUpdateController extends } // use the existing title in this image upload case $title = $conpherence->getTitle(); + $updated = true; + $fancy_ajax_style = false; } else if ($top !== null || $left !== null) { $file = $conpherence->getImage(ConpherenceImageData::SIZE_ORIG); $xformer = new PhabricatorImageTransformer(); @@ -115,12 +119,18 @@ final class ConpherenceUpdateController extends $xactions[] = id(new ConpherenceTransaction()) ->setTransactionType( ConpherenceTransactionType::TYPE_PICTURE_CROP) - ->setNewValue($image_phid); + ->setNewValue($image_phid); + $updated = true; } if ($title != $conpherence->getTitle()) { $xactions[] = id(new ConpherenceTransaction()) ->setTransactionType(ConpherenceTransactionType::TYPE_TITLE) ->setNewValue($title); + $updated = true; + } + if (!$updated && $request->isContinueRequest()) { + $errors[] = pht( + 'That was a non-update. Try cancel.'); } break; default: @@ -130,24 +140,21 @@ final class ConpherenceUpdateController extends if ($xactions) { try { $xactions = $editor->applyTransactions($conpherence, $xactions); - if ($latest_transaction_id) { - $content = $this->loadAndRenderNewTransactions( + if ($fancy_ajax_style) { + $content = $this->loadAndRenderUpdates( $conpherence_id, $latest_transaction_id); return id(new AphrontAjaxResponse()) ->setContent($content); } else { - return id(new AphrontRedirectResponse())->setURI( - $this->getApplicationURI($conpherence_id.'/')); + return id(new AphrontRedirectResponse()) + ->setURI($this->getApplicationURI($conpherence->getID().'/')); } } catch (PhabricatorApplicationTransactionNoEffectException $ex) { return id(new PhabricatorApplicationTransactionNoEffectResponse()) ->setCancelURI($this->getApplicationURI($conpherence_id.'/')) ->setException($ex); } - } else if (empty($errors)) { - $errors[] = pht( - 'That was a non-update. Try cancel.'); } } @@ -158,7 +165,29 @@ final class ConpherenceUpdateController extends ->setErrors($errors); } + switch ($action) { + case 'metadata': + default: + $dialogue = $this->renderMetadataDialogue($conpherence, $error_view); + break; + } + + return id(new AphrontDialogResponse()) + ->setDialog($dialogue + ->setUser($user) + ->setWidth(AphrontDialogView::WIDTH_FORM) + ->setSubmitURI($this->getApplicationURI('update/'.$conpherence_id.'/')) + ->addSubmitButton() + ->addCancelButton($this->getApplicationURI($conpherence->getID().'/'))); + + } + + private function renderMetadataDialogue( + ConpherenceThread $conpherence, + $error_view) { + $form = id(new AphrontFormLayoutView()) + ->appendChild($error_view) ->appendChild( id(new AphrontFormTextControl()) ->setLabel(pht('Title')) @@ -177,15 +206,15 @@ final class ConpherenceUpdateController extends 'src' => $conpherence->loadImageURI(ConpherenceImageData::SIZE_HEAD), )))) - ->appendChild( - id(new AphrontFormCropControl()) - ->setLabel(pht('Crop Image')) - ->setValue($image) - ->setWidth(ConpherenceImageData::HEAD_WIDTH) - ->setHeight(ConpherenceImageData::HEAD_HEIGHT)) - ->appendChild( - id(new ConpherenceFormDragAndDropUploadControl()) - ->setLabel(pht('Change Image'))); + ->appendChild( + id(new AphrontFormCropControl()) + ->setLabel(pht('Crop Image')) + ->setValue($image) + ->setWidth(ConpherenceImageData::HEAD_WIDTH) + ->setHeight(ConpherenceImageData::HEAD_HEIGHT)) + ->appendChild( + id(new ConpherenceFormDragAndDropUploadControl()) + ->setLabel(pht('Change Image'))); } else { $form ->appendChild( @@ -194,57 +223,57 @@ final class ConpherenceUpdateController extends } require_celerity_resource('conpherence-update-css'); - return id(new AphrontDialogResponse()) - ->setDialog( - id(new AphrontDialogView()) - ->setUser($user) - ->setTitle(pht('Update Conpherence')) - ->setWidth(AphrontDialogView::WIDTH_FORM) - ->setSubmitURI($this->getApplicationURI('update/'.$conpherence_id.'/')) - ->addHiddenInput('action', 'metadata') - ->appendChild($error_view) - ->appendChild($form) - ->addSubmitButton() - ->addCancelButton($this->getApplicationURI($conpherence->getID().'/'))); + return id(new AphrontDialogView()) + ->setTitle(pht('Update Conpherence')) + ->addHiddenInput('action', 'metadata') + ->addHiddenInput('__continue__', true) + ->appendChild($form); } - private function loadAndRenderNewTransactions( + private function loadAndRenderUpdates( $conpherence_id, $latest_transaction_id) { - $user = $this->getRequest()->getUser(); - $conpherence = id(new ConpherenceThreadQuery()) - ->setViewer($user) - ->setAfterID($latest_transaction_id) - ->needHeaderPics(true) - ->withIDs(array($conpherence_id)) - ->executeOne(); + $user = $this->getRequest()->getUser(); + $conpherence = id(new ConpherenceThreadQuery()) + ->setViewer($user) + ->setAfterID($latest_transaction_id) + ->needHeaderPics(true) + ->needWidgetData(true) + ->withIDs(array($conpherence_id)) + ->executeOne(); - $data = $this->renderConpherenceTransactions($conpherence); - $rendered_transactions = $data['transactions']; - $new_latest_transaction_id = $data['latest_transaction_id']; + $data = $this->renderConpherenceTransactions($conpherence); + $rendered_transactions = $data['transactions']; + $new_latest_transaction_id = $data['latest_transaction_id']; - $selected = true; - $nav_item = $this->buildConpherenceMenuItem( - $conpherence, - '-nav-item', - $selected); - $menu_item = $this->buildConpherenceMenuItem( - $conpherence, - '-menu-item', - $selected); + $selected = true; + $nav_item = $this->buildConpherenceMenuItem( + $conpherence, + '-nav-item', + $selected); + $menu_item = $this->buildConpherenceMenuItem( + $conpherence, + '-menu-item', + $selected); - $header = $this->buildHeaderPaneContent($conpherence); + $header = $this->buildHeaderPaneContent($conpherence); + + $file_widget = id(new ConpherenceFileWidgetView()) + ->setConpherence($conpherence) + ->setUpdateURI( + $this->getApplicationURI('update/'.$conpherence->getID().'/')); + + $content = array( + 'transactions' => $rendered_transactions, + 'latest_transaction_id' => $new_latest_transaction_id, + 'menu_item' => $menu_item->render(), + 'nav_item' => $nav_item->render(), + 'conpherence_phid' => $conpherence->getPHID(), + 'header' => $header, + 'file_widget' => $file_widget->render() + ); + return $content; + } - $content = array( - 'transactions' => $rendered_transactions, - 'latest_transaction_id' => $new_latest_transaction_id, - 'menu_item' => $menu_item->render(), - 'nav_item' => $nav_item->render(), - 'conpherence_phid' => $conpherence->getPHID(), - 'header' => $header - ); - return $content; } - -} diff --git a/src/applications/conpherence/controller/ConpherenceWidgetController.php b/src/applications/conpherence/controller/ConpherenceWidgetController.php index 85b7fd9104..b99ba4a122 100644 --- a/src/applications/conpherence/controller/ConpherenceWidgetController.php +++ b/src/applications/conpherence/controller/ConpherenceWidgetController.php @@ -55,6 +55,8 @@ final class ConpherenceWidgetController extends Javelin::initBehavior( 'conpherence-widget-pane', array( + 'form_pane' => 'conpherence-form', + 'file_widget' => 'widgets-files', 'widgetRegistery' => array( 'widgets-files' => 1, 'widgets-tasks' => 1, @@ -106,61 +108,38 @@ final class ConpherenceWidgetController extends 'class' => 'sprite-conpher conpher_calendar_off', ), '') - )). - phutil_tag( - 'div', - array( - 'class' => 'widgets-body', - 'id' => 'widgets-files', - 'style' => 'display: none;' - ), - $this->renderFilesWidgetPaneContent()). - phutil_tag( - 'div', - array( - 'class' => 'widgets-body', - 'id' => 'widgets-tasks', - ), - $this->renderTaskWidgetPaneContent()). - phutil_tag( - 'div', - array( - 'class' => 'widgets-body', - 'id' => 'widgets-calendar', - 'style' => 'display: none;' - ), - $this->renderCalendarWidgetPaneContent()); + )). + phutil_tag( + 'div', + array( + 'class' => 'widgets-body', + 'id' => 'widgets-files', + 'style' => 'display: none;' + ), + id(new ConpherenceFileWidgetView()) + ->setConpherence($conpherence) + ->setUpdateURI( + $this->getApplicationURI('update/'.$conpherence->getID().'/')) + ->render()). + phutil_tag( + 'div', + array( + 'class' => 'widgets-body', + 'id' => 'widgets-tasks', + ), + $this->renderTaskWidgetPaneContent()). + phutil_tag( + 'div', + array( + 'class' => 'widgets-body', + 'id' => 'widgets-calendar', + 'style' => 'display: none;' + ), + $this->renderCalendarWidgetPaneContent()); return array('widgets' => $widgets); } - private function renderFilesWidgetPaneContent() { - $conpherence = $this->getConpherence(); - $widget_data = $conpherence->getWidgetData(); - $files = $widget_data['files']; - - $table_data = array(); - foreach ($files as $file) { - $thumb = $file->getThumb60x45URI(); - $table_data[] = array( - phutil_tag( - 'img', - array( - 'src' => $thumb - ), - ''), - $file->getName() - ); - } - $header = id(new PhabricatorHeaderView()) - ->setHeader(pht('Attached Files')); - $table = id(new AphrontTableView($table_data)) - ->setNoDataString(pht('No files attached to conpherence.')) - ->setHeaders(array('', pht('Name'))) - ->setColumnClasses(array('', 'wide')); - return new PhutilSafeHTML($header->render() . $table->render()); - } - private function renderTaskWidgetPaneContent() { $conpherence = $this->getConpherence(); $widget_data = $conpherence->getWidgetData(); diff --git a/src/applications/conpherence/editor/ConpherenceEditor.php b/src/applications/conpherence/editor/ConpherenceEditor.php index 09b8e302d3..1a1426ea44 100644 --- a/src/applications/conpherence/editor/ConpherenceEditor.php +++ b/src/applications/conpherence/editor/ConpherenceEditor.php @@ -119,12 +119,22 @@ final class ConpherenceEditor extends PhabricatorApplicationTransactionEditor { $editor = id(new PhabricatorEdgeEditor()) ->setActor($this->getActor()); $edge_type = PhabricatorEdgeConfig::TYPE_OBJECT_HAS_FILE; - foreach ($xaction->getNewValue() as $file_phid) { + $old = array_fill_keys($xaction->getOldValue(), true); + $new = array_fill_keys($xaction->getNewValue(), true); + $add_edges = array_keys(array_diff_key($new, $old)); + $remove_edges = array_keys(array_diff_key($old, $new)); + foreach ($add_edges as $file_phid) { $editor->addEdge( $object->getPHID(), $edge_type, $file_phid); } + foreach ($remove_edges as $file_phid) { + $editor->removeEdge( + $object->getPHID(), + $edge_type, + $file_phid); + } $editor->save(); // fallthrough case PhabricatorTransactions::TYPE_COMMENT: diff --git a/src/applications/conpherence/storage/ConpherenceTransaction.php b/src/applications/conpherence/storage/ConpherenceTransaction.php index b2ff0f97c0..a3808b15c4 100644 --- a/src/applications/conpherence/storage/ConpherenceTransaction.php +++ b/src/applications/conpherence/storage/ConpherenceTransaction.php @@ -65,9 +65,28 @@ final class ConpherenceTransaction extends PhabricatorApplicationTransaction { } return $title; case ConpherenceTransactionType::TYPE_FILES: - return pht( - '%s updated the conpherence files.', - $this->renderHandleLink($author_phid)); + $add = array_diff($new, $old); + $rem = array_diff($old, $new); + + if ($add && $rem) { + $title = pht( + '%s edited files(s), added %d and removed %d.', + $this->renderHandleLink($author_phid), + count($add), + count($rem)); + } else if ($add) { + $title = pht( + '%s added %d files(s).', + $this->renderHandleLink($author_phid), + count($add)); + } else { + $title = pht( + '%s removed %d file(s).', + $this->renderHandleLink($author_phid), + count($rem)); + } + return $title; + break; case ConpherenceTransactionType::TYPE_PICTURE: return pht( '%s updated the conpherence image.', @@ -92,7 +111,7 @@ final class ConpherenceTransaction extends PhabricatorApplicationTransaction { $this->renderHandleList($add)); } else { $title = pht( - '%s removed %d partipant(s): %s.', + '%s removed %d participant(s): %s.', $this->renderHandleLink($author_phid), count($rem), $this->renderHandleList($rem)); diff --git a/src/applications/conpherence/view/ConpherenceFileWidgetView.php b/src/applications/conpherence/view/ConpherenceFileWidgetView.php new file mode 100644 index 0000000000..d85ec2020b --- /dev/null +++ b/src/applications/conpherence/view/ConpherenceFileWidgetView.php @@ -0,0 +1,65 @@ +updateURI = $update_uri; + return $this; + } + public function getUpdateURI() { + return $this->updateURI; + } + + public function setConpherence(ConpherenceThread $conpherence) { + $this->conpherence = $conpherence; + return $this; + } + public function getConpherence() { + return $this->conpherence; + } + + public function render() { + $conpherence = $this->getConpherence(); + $widget_data = $conpherence->getWidgetData(); + $files = $widget_data['files']; + + $table_data = array(); + + foreach ($files as $file) { + $file_view = id(new PhabricatorFileLinkView()) + ->setFilePHID($file->getPHID()) + ->setFileName($file->getName()) + ->setFileViewable(true) + ->setFileViewURI($file->getBestURI()); + $meta = $file_view->getMetadata(); + + $table_data[] = array( + javelin_tag( + 'a', + array( + 'sigil' => 'lightboxable', + 'meta' => $meta + ), + phutil_tag( + 'img', + array( + 'src' => $file->getThumb60x45URI() + ), + '')), + $file_view->render() + ); + } + $header = id(new PhabricatorHeaderView()) + ->setHeader(pht('Attached Files')); + $table = id(new AphrontTableView($table_data)) + ->setNoDataString(pht('No files attached to conpherence.')) + ->setHeaders(array('', pht('Name'))) + ->setColumnClasses(array('', 'wide wrap')); + return $this->renderSingleView(array($header, $table)); + + } + +} diff --git a/src/view/layout/PhabricatorFileLinkView.php b/src/view/layout/PhabricatorFileLinkView.php index ff3434d872..dd8c582771 100644 --- a/src/view/layout/PhabricatorFileLinkView.php +++ b/src/view/layout/PhabricatorFileLinkView.php @@ -48,6 +48,16 @@ final class PhabricatorFileLinkView extends AphrontView { return $this->fileName; } + public function getMetadata() { + return array( + 'phid' => $this->getFilePHID(), + 'viewable' => $this->getFileViewable(), + 'uri' => $this->getFileViewURI(), + 'dUri' => $this->getFileDownloadURI(), + 'name' => $this->getFileName(), + ); + } + public function render() { require_celerity_resource('phabricator-remarkup-css'); require_celerity_resource('lightbox-attachment-css'); @@ -57,14 +67,8 @@ final class PhabricatorFileLinkView extends AphrontView { $mustcapture = false; if ($this->getFileViewable()) { $mustcapture = true; - $sigil = 'lightboxable'; - $meta = array( - 'phid' => $this->getFilePHID(), - 'viewable' => $this->getFileViewable(), - 'uri' => $this->getFileViewURI(), - 'dUri' => $this->getFileDownloadURI(), - 'name' => $this->getFileName(), - ); + $sigil = 'lightboxable'; + $meta = $this->getMetadata(); } return javelin_tag( diff --git a/webroot/rsrc/css/application/conpherence/widget-pane.css b/webroot/rsrc/css/application/conpherence/widget-pane.css index 6cc2c4b19e..2d87aaa3b5 100644 --- a/webroot/rsrc/css/application/conpherence/widget-pane.css +++ b/webroot/rsrc/css/application/conpherence/widget-pane.css @@ -97,3 +97,13 @@ font-size: 11px; width: 260px; } + +.conpherence-widget-pane .widget-icon { + display: block; + height: 14px; + width: 14px; +} + +.conpherence-widget-pane .phabricator-remarkup-embed-layout-link { + padding-bottom: 1px; +} diff --git a/webroot/rsrc/js/application/conpherence/behavior-menu.js b/webroot/rsrc/js/application/conpherence/behavior-menu.js index 37a984334f..ae6339e9ae 100644 --- a/webroot/rsrc/js/application/conpherence/behavior-menu.js +++ b/webroot/rsrc/js/application/conpherence/behavior-menu.js @@ -2,14 +2,17 @@ * @provides javelin-behavior-conpherence-menu * @requires javelin-behavior * javelin-dom - * javelin-workflow - * javelin-util + * javelin-request * javelin-stratcom * javelin-uri + * javelin-util + * javelin-workflow */ JX.behavior('conpherence-menu', function(config) { + var root = JX.$(config.form_pane); + function onwidgetresponse(context, response) { var widgets = JX.$H(response.widgets); var widgetsRoot = JX.$(config.widgets_pane); @@ -107,14 +110,39 @@ JX.behavior('conpherence-menu', function(config) { } ); + JX.Stratcom.listen('click', 'conpherence-edit-metadata', function (e) { + e.kill(); + var form = JX.DOM.find(root, 'form'); + var data = e.getNodeData('conpherence-edit-metadata'); + new JX.Workflow.newFromForm(form, data) + .setHandler(function (r) { + // update the header + JX.DOM.setContent( + JX.$(config.header), + JX.$H(r.header) + ); + + // update the menu entry as well + JX.DOM.replace( + JX.$(r.conpherence_phid + '-nav-item'), + JX.$H(r.nav_item) + ); + JX.DOM.replace( + JX.$(r.conpherence_phid + '-menu-item'), + JX.$H(r.menu_item) + ); + }) + .start(); + }); + JX.Stratcom.listen('click', 'show-older-messages', function(e) { e.kill(); console.log(document.URL); - new JX.Request('/conpherence/view/1/', function(r) { - console.log('100'); - }) -.setData({offset: 100}) // get the next page -.send(); -}); + new JX.Request('/conpherence/view/1/', function(r) { + console.log('100'); + }) + .setData({offset: 100}) // get the next page + .send(); + }); }); diff --git a/webroot/rsrc/js/application/conpherence/behavior-pontificate.js b/webroot/rsrc/js/application/conpherence/behavior-pontificate.js index d3a064034f..b1fc9df43d 100644 --- a/webroot/rsrc/js/application/conpherence/behavior-pontificate.js +++ b/webroot/rsrc/js/application/conpherence/behavior-pontificate.js @@ -2,7 +2,8 @@ * @provides javelin-behavior-conpherence-pontificate * @requires javelin-behavior * javelin-dom - * javelin-request + * javelin-util + * javelin-workflow */ JX.behavior('conpherence-pontificate', function(config) { @@ -35,6 +36,12 @@ JX.behavior('conpherence-pontificate', function(config) { JX.$H(r.header) ); + // update the file widget + JX.DOM.setContent( + JX.$(config.file_widget), + JX.$H(r.file_widget) + ); + // clear the textarea var textarea = JX.DOM.find(form, 'textarea'); textarea.value = '';