[Fusionforge-commits] FusionForge branch master updated. v6.0.5-1292-g2cd5cda

Franck Villaume nerville at libremir.placard.fr.eu.org
Mon Dec 26 15:46:50 CET 2016


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "FusionForge".

The branch, master has been updated
       via  2cd5cda8b10e1fb1c3937742ab92676441760e46 (commit)
       via  b15855ab7aa97f6abc8fab0b13e7ba7e538fd6a6 (commit)
      from  c4c808007600d2aadb8fda50f7cb88e26ec42a49 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
https://scm.fusionforge.org/anonscm/gitweb/?p=fusionforge/fusionforge.git;a=commitdiff;h=2cd5cda8b10e1fb1c3937742ab92676441760e46

commit 2cd5cda8b10e1fb1c3937742ab92676441760e46
Author: Franck Villaume <franck.villaume at trivialdev.com>
Date:   Mon Dec 26 15:46:28 2016 +0100

    artifact display widget: add more preference settings: can modify number of columns, add/remove customfields, adjust position of customfields

diff --git a/src/common/widget/Widget_TrackerContent.class.php b/src/common/widget/Widget_TrackerContent.class.php
index cd44cea..ceb0316 100644
--- a/src/common/widget/Widget_TrackerContent.class.php
+++ b/src/common/widget/Widget_TrackerContent.class.php
@@ -43,6 +43,10 @@ class Widget_TrackerContent extends Widget {
 		return $this->trackercontent_title ? $hp->purify($this->trackercontent_title, CODENDI_PURIFIER_CONVERT_HTML)  : _('Tracker Content Box');
 	}
 
+	function getColumns() {
+		return $this->trackercolumns;
+	}
+
 	function isUnique() {
 		return false;
 	}
@@ -57,17 +61,21 @@ class Widget_TrackerContent extends Widget {
 
 	function loadContent($id) {
 		$this->content_id = $id;
-		$this->trackercontent_title = $this->getTitleBlock($id);
+		$this->fetchData($id);
+
 	}
 
-	function getTitleBlock($id) {
-		$res = db_query_params('select title from artifact_display_widget where id = $1', array($id));
+	function fetchData($id) {
+		$res = db_query_params('select * from artifact_display_widget where id = $1', array($id));
 		$title = false;
+		$columns = 0;
 		if ($res) {
 			$arr = db_fetch_array($res);
-			$title = $arr[0];
+			$title = $arr['title'];
+			$columns = $arr['cols'];
 		}
-		return $title;
+		$this->trackercontent_title = $title;
+		$this->trackercolumns = $columns;
 	}
 
 	function create(&$request) {
@@ -98,7 +106,7 @@ class Widget_TrackerContent extends Widget {
 		return html_e('p', array(), _('Number of vertical columns')._(':').html_e('input', array('type' => 'number', 'name' => 'columns', 'value' => $column_number, 'step' => 1, 'min' => 1, 'title' => _('Set number of columns to split your box into columns'))));
 	}
 
-	private function getExtraFieldsForm($owner_id) {
+	private function getAvailableExtraFieldsForm($owner_id) {
 		global $HTML;
 		$atid = $owner_id;
 		$artifactTypeObject = artifactType_get_object($atid);
@@ -120,6 +128,34 @@ class Widget_TrackerContent extends Widget {
 		return $content;
 	}
 
+	private function getExtraFieldsForm($id) {
+		global $HTML;
+		global $ath;
+		global $atid;
+		$artifactTypeObject = artifactType_get_object($atid);
+		$layoutExtraFieldIDs = $this->getLayoutExtraFieldIDs($id);
+		$content = html_e('p', array(), sprintf(_('Adjust already used ExtraFields from %s to display into this widget'), $artifactTypeObject->getName())._(':'));
+		if (count($layoutExtraFieldIDs) > 0) {
+			$content .= $HTML->listTableTop(array('', '', _('Column ID'), _('Row ID')));
+			foreach ($layoutExtraFieldIDs as $row_id => $column_id) {
+				foreach ($column_id as $key => $extrafieldIDs) {
+					foreach ($extrafieldIDs as $extrafieldID) {
+						$extrafieldObject = new ArtifactExtraField($ath, $extrafieldID);
+						$cells = array();
+						$cells[][] = $extrafieldObject->getName();
+						$cells[][] = html_e('input', array('type' => 'checkbox', 'name' => 'extrafieldids[]', 'value' => $extrafieldID, 'checked' => 'checked'));
+						$cells[][] = html_e('input', array('type' => 'number', 'name' => 'extrafield_column_ids[]', 'value' => $key, 'step' => 1, 'min' => 1, 'title' => _('Set the column number accordingly to the number of columns you created')));
+						$cells[][] = html_e('input', array('type' => 'number', 'name' => 'extrafield_row_ids[]', 'value' => $row_id, 'step' => 1, 'min' => 1, 'title' => _('Set the row number accordingly to organize the extrafields')));
+						$content .= $HTML->multiTableRow(array('class' => $HTML->boxGetAltRowStyle($key, true)), $cells);
+					}
+				}
+			}
+			$content .= $HTML->listTableBottom();
+		}
+		return $content;
+
+	}
+
 	private function availableExtrafields($owner_id, $extrafields) {
 		$arr = $this->getExtraFieldIDs($owner_id);
 		$availableExtrafields = array();
@@ -157,7 +193,7 @@ class Widget_TrackerContent extends Widget {
 		$owner_id = (int)substr($request->get('owner'), 1);
 		$content = $this->getPartialPreferencesFormTitle(_('Enter title of Tracker Content Box'));
 		$content .= $this->getPartialPreferencesFormColumns(1);
-		$content .= $this->getExtraFieldsForm($owner_id);
+		$content .= $this->getAvailableExtraFieldsForm($owner_id);
 		return $content;
 	}
 
@@ -445,7 +481,10 @@ class Widget_TrackerContent extends Widget {
 	}
 
 	function getPreferences() {
-		return $this->getPartialPreferencesFormTitle($this->getTitle());
+		return $this->getPartialPreferencesFormTitle($this->getTitle()).
+			$this->getPartialPreferencesFormColumns($this->getColumns()).
+			$this->getAvailableExtraFieldsForm($this->owner_id).
+			$this->getExtraFieldsForm($this->content_id);
 	}
 
 	function getPreferencesForm($layout_id, $owner_id, $owner_type) {
@@ -478,12 +517,31 @@ class Widget_TrackerContent extends Widget {
 			} else {
 				$title = '';
 			}
+			$vColumns = new Valid_String('columns');
+			if($request->valid($vColumns)) {
+				$columns = (int)$request->get('columns');
+			} else {
+				$columns = 1;
+			}
 
 			if ($title) {
 				$sql = "UPDATE artifact_display_widget SET title = $1 WHERE owner_id =$2 AND id = $3";
 				$res = db_query_params($sql,array($title, $this->owner_id, (int)$request->get('content_id')));
 				$done = true;
 			}
+			if ($columns) {
+				$sql = "UPDATE artifact_display_widget SET cols = $1 WHERE owner_id =$2 AND id = $3";
+				$res = db_query_params($sql,array($columns, $this->owner_id, (int)$request->get('content_id')));
+				$done = true;
+			}
+			$extrafieldIDs = getArrayFromRequest('extrafieldids');
+			$extrafieldIDColumns = getArrayFromRequest('extrafield_column_ids');
+			$extrafieldIDRows = getArrayFromRequest('extrafield_row_ids');
+			$res = db_query_params('DELETE FROM artifact_display_widget_field WHERE id = $1', array((int)$request->get('content_id')));
+			foreach ($extrafieldIDs as $key => $extrafieldID) {
+				db_query_params('INSERT INTO artifact_display_widget_field (id, field_id, column_id, row_id) VALUES ($1, $2, $3, $4)', array((int)$request->get('content_id'), $extrafieldID, $extrafieldIDColumns[$key], $extrafieldIDRows[$key]));
+				$done = true;
+			}
 		}
 		return $done;
 	}

https://scm.fusionforge.org/anonscm/gitweb/?p=fusionforge/fusionforge.git;a=commitdiff;h=b15855ab7aa97f6abc8fab0b13e7ba7e538fd6a6

commit b15855ab7aa97f6abc8fab0b13e7ba7e538fd6a6
Author: Franck Villaume <franck.villaume at trivialdev.com>
Date:   Mon Dec 26 14:21:33 2016 +0100

    artifact Display widget: add direct access to widget menu from update settings admin link

diff --git a/src/common/tracker/actions/widget_artifact_display.php b/src/common/tracker/actions/widget_artifact_display.php
index e6af67c..5adfec5 100644
--- a/src/common/tracker/actions/widget_artifact_display.php
+++ b/src/common/tracker/actions/widget_artifact_display.php
@@ -35,15 +35,13 @@ if (!isset($func)) {
 	$func = getStringFromRequest('func');
 }
 
-$sql = "SELECT l.*
-		FROM layouts AS l INNER JOIN owner_layouts AS o ON(l.id = o.layout_id)
+$lm = new WidgetLayoutManager();
+$sql = "SELECT l.* FROM layouts AS l INNER JOIN owner_layouts AS o ON(l.id = o.layout_id)
 		WHERE o.owner_type = $1
 		AND o.owner_id = $2
-		AND o.is_default = 1
-		";
+		AND o.is_default = 1";
 $res = db_query_params($sql,array('t', $atid));
-if($res && db_numrows($res)<1) {
-	$lm = new WidgetLayoutManager();
+if($res && db_numrows($res) < 1) {
 	$lm->createDefaultLayoutForTracker($atid);
 	$res = db_query_params($sql,array('t', $atid));
 }
@@ -58,17 +56,19 @@ if ($func == 'add') {
 }
 
 if (forge_check_perm('tracker_admin', $atid)) {
-	$ap = html_ap();
-	echo html_ao('ul', array('class' => 'widget_toolbar'));
 	$url = '/widgets/widgets.php?owner=t'.$atid.'&layout_id='.$id;
 	$labels = array(_('Add widgets'), _('Customize Layout'));
 	$urls = array($url, $url.'&update=layout');
+	$attrs = array();
+	$attrs[] = array('title' => _('Customfields must be linked to a widget to be displayed. Use “Add widgets” to create new widget to link and organize your customfields.'));
+	$attrs[] = array('title' => _('General layout to display “Submit New” form or detailed view of an existing artifact can be customize. Use “Customize Layout” to that purpose.'));
+	$elementsLi = array();
 	for ($i = 0; $i < count($urls); $i++) {
-		echo html_e('li', array(), util_make_link($urls[$i], $labels[$i]));
+		$elementsLi[] = array('content' => util_make_link($urls[$i], $labels[$i]), 'attrs' => $attrs[$i]);
 	}
-	echo html_ac($ap);
+	echo $HTML->html_list($elementsLi, array('class' => 'widget_toolbar'));
 }
-// plugin_hook('message');
+
 echo $HTML->openForm(array('id' => 'trackerform', 'name' => 'trackerform', 'action' => '/tracker/?group_id='.$group_id.'&atid='.$ath->getID(), 'enctype' => 'multipart/form-data', 'method' => 'post'));
 echo html_e('input', array('type' => 'hidden', 'name' => 'form_key', 'value' => form_generate_key(), 'form' => 'trackerform'));
 if ($func == 'add') {
@@ -78,6 +78,5 @@ if ($func == 'add') {
 	echo html_e('input', array('type' => 'hidden', 'name' => 'artifact_id', 'value' => $ah->getID(), 'form' => 'trackerform'));
 }
 echo $HTML->closeForm();
-$lm = new WidgetLayoutManager();
 $lm->displayLayout($atid, WidgetLayoutManager::OWNER_TYPE_TRACKER);
 $ath->footer();
diff --git a/src/common/tracker/views/form-updatetracker.php b/src/common/tracker/views/form-updatetracker.php
index 4cac282..b08e13a 100644
--- a/src/common/tracker/views/form-updatetracker.php
+++ b/src/common/tracker/views/form-updatetracker.php
@@ -40,6 +40,32 @@ $browse_instructions = getStringFromRequest('browse_instructions', $ath->getBrow
 $ath->adminHeader(array('title'=>sprintf(_('Update settings for %s'),
 	$ath->getName()),
 	'modal'=>1));
+
+if (forge_get_config('use_tracker_widget_display')) {
+	$sql = "SELECT l.* FROM layouts AS l INNER JOIN owner_layouts AS o ON(l.id = o.layout_id)
+			WHERE o.owner_type = $1
+			AND o.owner_id = $2
+			AND o.is_default = 1";
+	$res = db_query_params($sql,array('t', $atid));
+	if($res && db_numrows($res) < 1) {
+		$lm = new WidgetLayoutManager();
+		$lm->createDefaultLayoutForTracker($atid);
+		$res = db_query_params($sql,array('t', $atid));
+	}
+	$id = db_result($res, 0 , 'id');
+	$url = '/widgets/widgets.php?owner=t'.$atid.'&layout_id='.$id;
+	$labels = array(_('Add widgets'), _('Customize Layout'));
+	$attrs = array();
+	$attrs[] = array('title' => _('Customfields must be linked to a widget to be displayed. Use “Add widgets” to create new widget to link and organize your customfields.'));
+	$attrs[] = array('title' => _('General layout to display “Submit New” form or detailed view of an existing artifact can be customize. Use “Customize Layout” to that purpose.'));
+	$urls = array($url, $url.'&update=layout');
+	$elementsLi = array();
+	for ($i = 0; $i < count($urls); $i++) {
+		$elementsLi[] = array('content' => util_make_link($urls[$i], $labels[$i]), 'attrs' => $attrs[$i]);
+	}
+	echo $HTML->html_list($elementsLi, array('class' => 'widget_toolbar'));
+}
+
 echo $HTML->openForm(array('action' => '/tracker/admin/?group_id='.$group_id.'&atid='.$ath->getID(), 'method' => 'post'));
 
 echo html_e('input', array('type'=>'hidden', 'name'=>'update_type', 'value'=>'y'));
@@ -103,7 +129,7 @@ echo html_e('input', array('type'=>'submit', 'name'=>'post_changes', 'value'=>_(
 echo html_ac(html_ap()-1);
 
 echo $HTML->closeForm();
-	$ath->footer();
+$ath->footer();
 
 // Local Variables:
 // mode: php

-----------------------------------------------------------------------

Summary of changes:
 .../tracker/actions/widget_artifact_display.php    | 23 ++++---
 src/common/tracker/views/form-updatetracker.php    | 28 +++++++-
 src/common/widget/Widget_TrackerContent.class.php  | 74 +++++++++++++++++++---
 3 files changed, 104 insertions(+), 21 deletions(-)


hooks/post-receive
-- 
FusionForge



More information about the Fusionforge-commits mailing list