Merge pull request #833 from nlegoff/fix_1607

[3.8] Fix #1607 Reoder collections is not working
This commit is contained in:
Romain Neutron
2013-12-16 05:18:53 -08:00
4 changed files with 21 additions and 9 deletions

View File

@@ -18,7 +18,7 @@ namespace Alchemy\Phrasea\Core;
*/ */
class Version class Version
{ {
protected static $number = '3.8.3-alpha.2'; protected static $number = '3.8.3-alpha.3';
protected static $name = 'Diplodocus'; protected static $name = 'Diplodocus';
public static function getNumber() public static function getNumber()

View File

@@ -565,6 +565,12 @@ class collection implements cache_cacheableInterface
</sugestedValues> </sugestedValues>
</baseprefs>'; </baseprefs>';
$sql = "SELECT GREATEST(0, MAX(ord)) + 1 AS ord FROM bas WHERE sbas_id = :sbas_id";
$stmt = $conn->prepare($sql);
$stmt->execute(array(':sbas_id' => $sbas_id));
$ord = $stmt->fetch(\PDO::FETCH_ASSOC);
$stmt->closeCursor();
$sql = "INSERT INTO coll (coll_id, asciiname, prefs, logo) $sql = "INSERT INTO coll (coll_id, asciiname, prefs, logo)
VALUES (null, :name, :prefs, '')"; VALUES (null, :name, :prefs, '')";
@@ -579,11 +585,15 @@ class collection implements cache_cacheableInterface
$new_id = (int) $connbas->lastInsertId(); $new_id = (int) $connbas->lastInsertId();
$sql = "INSERT INTO bas (base_id, active, server_coll_id, sbas_id, aliases) $sql = "INSERT INTO bas (base_id, active, ord, server_coll_id, sbas_id, aliases)
VALUES VALUES
(null, 1, :server_coll_id, :sbas_id, '')"; (null, 1, :ord, :server_coll_id, :sbas_id, '')";
$stmt = $conn->prepare($sql); $stmt = $conn->prepare($sql);
$stmt->execute(array(':server_coll_id' => $new_id, ':sbas_id' => $sbas_id)); $stmt->execute(array(
':server_coll_id' => $new_id,
':sbas_id' => $sbas_id,
':ord' => $ord['ord'] ?: 1,
));
$stmt->closeCursor(); $stmt->closeCursor();
$new_bas = $conn->lastInsertId(); $new_bas = $conn->lastInsertId();
@@ -638,7 +648,7 @@ class collection implements cache_cacheableInterface
VALUES VALUES
(null, 1, :server_coll_id, :sbas_id, '')"; (null, 1, :server_coll_id, :sbas_id, '')";
$stmt = $databox->get_appbox()->get_connection()->prepare($sql); $stmt = $databox->get_appbox()->get_connection()->prepare($sql);
$stmt->execute(array(':server_coll_id' => $coll_id, ':sbas_id' => $sbas_id)); $stmt->execute(array(':server_coll_id' => $coll_id, ':sbas_id' => $databox->get_sbas_id()));
$stmt->closeCursor(); $stmt->closeCursor();
$new_bas = $databox->get_appbox()->get_connection()->lastInsertId(); $new_bas = $databox->get_appbox()->get_connection()->lastInsertId();
@@ -646,7 +656,7 @@ class collection implements cache_cacheableInterface
$databox->delete_data_from_cache(databox::CACHE_COLLECTIONS); $databox->delete_data_from_cache(databox::CACHE_COLLECTIONS);
cache_databox::update($app, $sbas_id, 'structure'); cache_databox::update($app, $databox->get_sbas_id(), 'structure');
phrasea::reset_baseDatas($databox->get_appbox()); phrasea::reset_baseDatas($databox->get_appbox());

View File

@@ -11,10 +11,10 @@
use Alchemy\Phrasea\Application; use Alchemy\Phrasea\Application;
class patch_381alpha1a implements patchInterface class patch_383alpha3a implements patchInterface
{ {
/** @var string */ /** @var string */
private $release = '3.8.1-alpha.1'; private $release = '3.8.3-alpha.3';
/** @var array */ /** @var array */
private $concern = array(base::APPLICATION_BOX); private $concern = array(base::APPLICATION_BOX);

View File

@@ -2,6 +2,8 @@
<h1>{% trans 'Reorder collections' %}</h1> <h1>{% trans 'Reorder collections' %}</h1>
</div> </div>
<div id="notification"></div>
<table id="table-order"> <table id="table-order">
<tr> <tr>
<td valign="center" align="center"> <td valign="center" align="center">
@@ -87,7 +89,7 @@
var html = _.template($("#alert_"+ (datas.success ? "success" : "error") +"_tpl").html(), { var html = _.template($("#alert_"+ (datas.success ? "success" : "error") +"_tpl").html(), {
content:datas.msg content:datas.msg
}); });
$('#table-order').insertBefore(html); $('#notification').html(html);
}, },
complete : function() { complete : function() {
$this.attr('disabled', false); $this.attr('disabled', false);