Merge pull request #754 from electerious/develop
* Drag and Drop Sorting using Jquery-ui * Updating database tables * version 3.1.7
This commit is contained in:
parent
ab0f86f5fb
commit
20a1ff2d61
BIN
dist/main.css
vendored
BIN
dist/main.css
vendored
Binary file not shown.
BIN
dist/main.js
vendored
BIN
dist/main.js
vendored
Binary file not shown.
BIN
dist/view.js
vendored
BIN
dist/view.js
vendored
Binary file not shown.
@ -26,6 +26,7 @@ final class Admin extends Access {
|
|||||||
case 'Album::setTitle': self::setAlbumTitleAction(); break;
|
case 'Album::setTitle': self::setAlbumTitleAction(); break;
|
||||||
case 'Album::setDescription': self::setAlbumDescriptionAction(); break;
|
case 'Album::setDescription': self::setAlbumDescriptionAction(); break;
|
||||||
case 'Album::setPublic': self::setAlbumPublicAction(); break;
|
case 'Album::setPublic': self::setAlbumPublicAction(); break;
|
||||||
|
case 'Album::setPosition': self::setPositionAction(); break;
|
||||||
case 'Album::delete': self::deleteAlbumAction(); break;
|
case 'Album::delete': self::deleteAlbumAction(); break;
|
||||||
case 'Album::merge': self::mergeAlbumsAction(); break;
|
case 'Album::merge': self::mergeAlbumsAction(); break;
|
||||||
|
|
||||||
@ -115,6 +116,15 @@ final class Admin extends Access {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static function setPositionAction() {
|
||||||
|
|
||||||
|
Validator::required(isset($_POST['albumID'],$_POST['photoOrder']), __METHOD__);
|
||||||
|
|
||||||
|
$album = new Album($_POST['albumID']);
|
||||||
|
Response::json($album->setPosition());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
private static function setAlbumPublicAction() {
|
private static function setAlbumPublicAction() {
|
||||||
|
|
||||||
Validator::required(isset($_POST['albumID'], $_POST['password'], $_POST['visible'], $_POST['downloadable']), __METHOD__);
|
Validator::required(isset($_POST['albumID'], $_POST['password'], $_POST['visible'], $_POST['downloadable']), __METHOD__);
|
||||||
|
@ -344,6 +344,41 @@ final class Album {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function setPosition(){
|
||||||
|
// Check dependencies
|
||||||
|
Validator::required(isset($_POST['photoOrder']), __METHOD__);
|
||||||
|
|
||||||
|
// Call plugins
|
||||||
|
Plugins::get()->activate(__METHOD__, 0, func_get_args());
|
||||||
|
|
||||||
|
$id_list = implode(',', $_POST['photoOrder']);
|
||||||
|
$indices = [];
|
||||||
|
$size = count(explode(',',$id_list));
|
||||||
|
for($i = 0; $i < $size; $i++){
|
||||||
|
$indices[$i] = $i;
|
||||||
|
}
|
||||||
|
|
||||||
|
$whens = implode(
|
||||||
|
" ",
|
||||||
|
array_map(
|
||||||
|
function ($id, $value) {
|
||||||
|
return "WHEN {$id} THEN {$value}";
|
||||||
|
},
|
||||||
|
explode(',',$id_list),
|
||||||
|
$indices
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
$query = Database::prepare(Database::get(), "UPDATE ? SET position = CASE id ? END WHERE id IN (?)", array(LYCHEE_TABLE_PHOTOS, $whens, $id_list));
|
||||||
|
$result = Database::execute(Database::get(), $query, __METHOD__, __LINE__);
|
||||||
|
|
||||||
|
// Call plugins
|
||||||
|
Plugins::get()->activate(__METHOD__, 1, func_get_args());
|
||||||
|
|
||||||
|
if ($result===false) return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return boolean Returns true when successful.
|
* @return boolean Returns true when successful.
|
||||||
*/
|
*/
|
||||||
|
@ -24,6 +24,7 @@ CREATE TABLE IF NOT EXISTS `?` (
|
|||||||
`album` bigint(20) unsigned NOT NULL,
|
`album` bigint(20) unsigned NOT NULL,
|
||||||
`checksum` char(40) DEFAULT NULL,
|
`checksum` char(40) DEFAULT NULL,
|
||||||
`medium` tinyint(1) NOT NULL DEFAULT '0',
|
`medium` tinyint(1) NOT NULL DEFAULT '0',
|
||||||
|
`position` tinyint(1) NOT NULL,
|
||||||
PRIMARY KEY (`id`),
|
PRIMARY KEY (`id`),
|
||||||
KEY `Index_album` (`album`),
|
KEY `Index_album` (`album`),
|
||||||
KEY `Index_star` (`star`)
|
KEY `Index_star` (`star`)
|
||||||
|
25
php/database/update_030107.php
Normal file
25
php/database/update_030107.php
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update to version 3.1.7
|
||||||
|
*/
|
||||||
|
|
||||||
|
use Lychee\Modules\Database;
|
||||||
|
use Lychee\Modules\Response;
|
||||||
|
|
||||||
|
// Add position to photos
|
||||||
|
$query = Database::prepare($connection, "SELECT `position` FROM `?` LIMIT 1", array(LYCHEE_TABLE_PHOTOS));
|
||||||
|
$result = Database::execute($connection, $query, 'update_030107', __LINE__);
|
||||||
|
|
||||||
|
if ($result===false) {
|
||||||
|
|
||||||
|
$query = Database::prepare($connection, "ALTER TABLE `?` ADD `position` TINYINT(1) NOT NULL", array(LYCHEE_TABLE_PHOTOS));
|
||||||
|
$result = Database::execute($connection, $query, 'update_030107', __LINE__);
|
||||||
|
|
||||||
|
if ($result===false) Response::error('Could not add position to database!');
|
||||||
|
|
||||||
|
}
|
||||||
|
// Set version
|
||||||
|
if (Database::setVersion($connection, '030107')===false) Response::error('Could not update version of database!');
|
||||||
|
|
||||||
|
?>
|
@ -83,6 +83,7 @@ paths.main = {
|
|||||||
],
|
],
|
||||||
scripts: [
|
scripts: [
|
||||||
'node_modules/jquery/dist/jquery.min.js',
|
'node_modules/jquery/dist/jquery.min.js',
|
||||||
|
'node_modules/jquery-ui-dist/jquery-ui.min.js',
|
||||||
'node_modules/mousetrap/mousetrap.min.js',
|
'node_modules/mousetrap/mousetrap.min.js',
|
||||||
'node_modules/mousetrap/plugins/global-bind/mousetrap-global-bind.min.js',
|
'node_modules/mousetrap/plugins/global-bind/mousetrap-global-bind.min.js',
|
||||||
'node_modules/basiccontext/dist/basicContext.min.js',
|
'node_modules/basiccontext/dist/basicContext.min.js',
|
||||||
|
@ -28,6 +28,7 @@
|
|||||||
"gulp-sass": "^3.1.0",
|
"gulp-sass": "^3.1.0",
|
||||||
"gulp-uglify": "^2.1.1",
|
"gulp-uglify": "^2.1.1",
|
||||||
"jquery": "^3.2.0",
|
"jquery": "^3.2.0",
|
||||||
|
"jquery-ui": "^1.12.1",
|
||||||
"mousetrap": "^1.6.0"
|
"mousetrap": "^1.6.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,6 +30,21 @@ album.getID = function() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
album.load = function(albumID, refresh = false) {
|
album.load = function(albumID, refresh = false) {
|
||||||
|
$('.content').sortable({
|
||||||
|
stop: function(event, ui){
|
||||||
|
let albumID = ui.item.data('album-id');
|
||||||
|
let photoOrder = $('.content').children().map(function(){
|
||||||
|
return $(this).data('id');
|
||||||
|
}).get();
|
||||||
|
let params = {
|
||||||
|
albumID: albumID,
|
||||||
|
photoOrder: photoOrder
|
||||||
|
};
|
||||||
|
api.post('Album::setPosition', params, function(data) {
|
||||||
|
if (data!==true) lychee.error(null, params, data)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
password.get(albumID, function() {
|
password.get(albumID, function() {
|
||||||
|
|
||||||
|
@ -5,8 +5,8 @@
|
|||||||
lychee = {
|
lychee = {
|
||||||
|
|
||||||
title : document.title,
|
title : document.title,
|
||||||
version : '3.1.6',
|
version : '3.1.7',
|
||||||
versionCode : '030106',
|
versionCode : '030107',
|
||||||
|
|
||||||
updatePath : '//update.electerious.com/index.json',
|
updatePath : '//update.electerious.com/index.json',
|
||||||
updateURL : 'https://github.com/electerious/Lychee',
|
updateURL : 'https://github.com/electerious/Lychee',
|
||||||
|
Loading…
Reference in New Issue
Block a user