Skip to content

Commit

Permalink
Finish 5.3.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Schlaefer committed Sep 1, 2019
2 parents d7e193e + 6c042c7 commit bceb3a7
Show file tree
Hide file tree
Showing 23 changed files with 146 additions and 148 deletions.
11 changes: 0 additions & 11 deletions config/Migrations/20190729142650_Saitox5x3x0.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,6 @@ public function up()
'length' => 191,
'null' => true,
])
->addIndex(
[
'user_id',
'title',
],
['name' => 'userId_title', 'unique' => true]
)
->update();

$this->table('useronline')
Expand Down Expand Up @@ -76,10 +69,6 @@ public function up()

public function down()
{
$this->table('uploads')
->removeIndexByName('userId_title')
->update();

$this->table('uploads')
->changeColumn('title', 'string', [
'default' => null,
Expand Down
55 changes: 55 additions & 0 deletions config/Migrations/20190801000000_Saitox5x3x1.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?php
use Migrations\AbstractMigration;
use Phinx\Db\Action\ChangeColumn;

class Saitox5x3x1 extends AbstractMigration
{
public function up()
{
// Only apply on installations which made it to 5.3.0. See #347.
if ($this->table('uploads')->hasIndex(['user_id', 'title'])) {
// Remove existing index on title from 5.3.0
$this->table('uploads')
->removeIndexByName('userId_title')
->update();
}

// Populate all NULL title fields from name
$this->execute('UPDATE `uploads` SET `uploads`.`title`=COALESCE(`uploads`.`title`, `uploads`.`name`)');

// Change title to NOT NULL
$this->table('uploads')
->changeColumn('title', 'string', [
'default' => null,
'length' => 191,
'null' => false,
])
->update();

// Unique index on title
$this->table('uploads')
->addIndex(
[
'user_id',
'title',
],
['name' => 'userId_title', 'unique' => true]
)
->update();
}

public function down()
{
$this->table('uploads')
->removeIndexByName('userId_title')
->update();

$this->table('uploads')
->changeColumn('title', 'string', [
'default' => null,
'length' => 191,
'null' => true,
])
->update();
}
}
6 changes: 3 additions & 3 deletions docs/help/de/9-drafts.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
## Entwürfe

Entwürfe sollen Datenverlust beim Verfassen eines neuen Beitrages vermeiden helfen.
Entwürfe helfen einen Datenverlust beim Verfassen eines neuen Beitrages zu vermeiden.

Der Inhalt des Beitrages wird regelmässig im Hintergrund gespeichert. Sollte es zu Problemen beim Nutzer kommen (bspw. unerwartetes Schließen des Browsers), kann der bis dahin gesicherte Inhalt später wieder hergestellt werden. Dazu muss nur ein Beitrag an der gleichen Stelle wie zuvor begonnen werden, der Inhalt eines Entwurfs wird automatisch eingefügt.
Der Inhalt des Beitrages wird regelmässig im Hintergrund gespeichert. Sollte es zu einem Problem beim Nutzer kommen (bspw. unerwartetes Beenden des Browsers), kann der bis dahin gesicherte Inhalt später wieder hergestellt werden. Dazu muss ein zuvor begonnener Beitrag an der gleichen Stelle erneut geöffnet werden, der Entwurf wird dann automatisch eingefügt.

Ein Ikon zeigt den aktuellen Status an:

- <i class="fa fa-pencil" aria-hidden="true"></i> &nbsp; Änderungen ungesichert
- <i class="fa fa-floppy-o" aria-hidden="true"></i> &nbsp; Änderungen gesichert

Nach erfolgreichen Eintragen eines Beitrags wird der entsprechende Entwurf gelöscht. Entwürfe werden nach 30 Tagen als aufgegeben angesehen automatisch entfernt.
Nach erfolgreichen Eintragen eines Beitrags wird der entsprechende Entwurf gelöscht. Alle Entwürfe werden spätestens nach 30 Tagen als aufgegeben angenommen und automatisch entfernt.

Beim Bearbeiten eines bestehenden Beitrages wird kein Entwurf gespeichert.
52 changes: 27 additions & 25 deletions frontend/src/app/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,34 +105,36 @@ var app = {
let appView,
appReady;

// do this always first
App.settings.set(options.SaitoApp.app.settings);
// init i18n, do this always second
const language = App.settings.get('language');
$.i18n.setUrl(App.settings.get('webroot') + 'js/locale/' + language + '.json');

App.currentUser.set(options.SaitoApp.currentUser);
App.request = options.SaitoApp.request;

app.configureAjax($, App);

Html5NotificationModule.start();

var callbacks = options.SaitoApp.callbacks.beforeAppInit;
_.each(callbacks, function (fct) {
fct();
$.ajax({
cache: true,
dataType: 'json',
mimeType: 'application/json',
success: (data) => {
$.i18n.setDictionary(data);
App.currentUser.set(options.SaitoApp.currentUser);
App.request = options.SaitoApp.request;

app.configureAjax($, App);

Html5NotificationModule.start();

var callbacks = options.SaitoApp.callbacks.beforeAppInit;
_.each(callbacks, (fct) => { fct(); });

appReady = function () {
app.fireOnPageCallbacks(options.SaitoApp.callbacks);
appView = new AppView({ el: 'body' });
appView.initFromDom({
SaitoApp: options.SaitoApp,
contentTimer: contentTimer
});
};
whenReady(appReady);
},
url: options.SaitoApp.assets.lang,
});

appReady = function () {
app.fireOnPageCallbacks(options.SaitoApp.callbacks);
appView = new AppView({ el: 'body' });
appView.initFromDom({
SaitoApp: options.SaitoApp,
contentTimer: contentTimer
});
};

whenReady(appReady);
}
};

Expand Down
26 changes: 0 additions & 26 deletions frontend/src/lib/jquery.i18n/jquery.i18n.extend.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,32 +7,6 @@ import i18n from 'lib/jquery.i18n/jquery.i18n';
import format from 'string-template';

$.extend($.i18n, {

currentString: '',

setDict: function (dict) {
this.dict = dict;
},

setUrl: function (dictUrl) {
this.dictUrl = dictUrl;
this._loadDict();
},

_loadDict: function () {
var success = function(data) {
this.dict = data;
};
success = $.proxy(success, this);
return $.ajax({
url: this.dictUrl,
dataType: 'json',
mimeType: 'application/json',
async: false,
cache: true
}).done(success);
},

/**
* Localice string with tokens
*
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/modules/answering/editor/EditorView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ class EditorView extends View<Model> {
*/
private postContentChanged() {
this.handleInput();
autosize.update(this.getUI('text'));
_.defer(() => autosize.update(this.getUI('text')));
}

/**
Expand Down
8 changes: 4 additions & 4 deletions frontend/src/modules/answering/views/CategorySelectVw.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ export default class CategorySelectVw extends View<Model> {
<% if (!autoselectCategory) { %>
<option value=""></option>
<% } %>
<% for (const [id, title] of Object.entries(categories)) { %>
<% for (category of categories) { %>
<option
value="<%= id %>"
<% if (category_id == id) { %>selected="selected"<% } %>
value="<%= category.id %>"
<% if (category_id == category.id) { %>selected="selected"<% } %>
>
<%- title %>
<%- category.title %>
</option>
<% } %>
</select>
Expand Down
2 changes: 1 addition & 1 deletion frontend/test/lib/TemplateHelpersSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import moment from 'moment';
import TemplateHelpers from 'lib/saito/templateHelpers';
// import 'lib/jquery.i18n/jquery.i18n.extend.js';

$.i18n.setDict({});
$.i18n.setDictionary({});


describe('Template Helpers', function () {
Expand Down
4 changes: 2 additions & 2 deletions frontend/test/lib/jquery.i18n.extendSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import 'lib/jquery.i18n/jquery.i18n.extend';
describe('jquery.i18n.extend', function () {
describe('replaces :token tags', function () {
beforeEach(function (done) {
$.i18n.setDict({});
$.i18n.setDictionary({});
done();
});

Expand All @@ -25,7 +25,7 @@ describe('jquery.i18n.extend', function () {
var expected,
result;

$.i18n.setDict({
$.i18n.setDictionary({
'token test': '{tokenA}; is {token_b} than fu {tokenNo} c'
});

Expand Down
2 changes: 1 addition & 1 deletion frontend/test/modules/answering/AnsweringVwSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ describe('answering form', () => {
},
editor: {
buttons: [],
categories: {1: 'Ontopic'},
categories: [{ id: 1, title: 'Ontopic'}],
smilies: [],
},
meta: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ import { SubjectInputView as View } from 'modules/answering/views/SubjectInputVw
import _ from 'underscore';

describe('answering form', function () {
const categories = { 1: 'Ontopic', 2: 'Offtopic'};
const categories = [
{ id: 1, title: 'Ontopic'},
{ id: 2, title: 'Offtopic'}
];
let model;

beforeEach(() => {
Expand Down
2 changes: 1 addition & 1 deletion frontend/test/runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ window.$ = $;
$.ajaxSetup({cache: true});

// make empty dict available for test cases
$.i18n.setDict({});
$.i18n.setDictionary({});

window.redirect = function (destination) {
document.location.replace(destination);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function image(Upload $image): array
'created' => $image->get('created'),
'mime' => $image->get('type'),
'name' => $image->get('name'),
'title' => $image->get('title') ?: $image->get('name'),
'title' => $image->get('title'),
'size' => $image->get('size'),
'url' => $this->Url->assetUrl(
'useruploads/' . $image->get('name'),
Expand Down
6 changes: 3 additions & 3 deletions plugins/ImageUploader/tests/Fixture/UploadsFixture.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class UploadsFixture extends TestFixture
public $fields = [
'id' => ['type' => 'integer', 'length' => 11, 'unsigned' => false, 'null' => false, 'default' => null, 'comment' => '', 'autoIncrement' => true, 'precision' => null],
'name' => ['type' => 'string', 'length' => 200, 'null' => true, 'default' => null, 'collate' => 'utf8mb4_unicode_ci', 'comment' => '', 'precision' => null, 'fixed' => null],
'title' => ['type' => 'string', 'length' => 191, 'null' => true, 'default' => null, 'collate' => 'utf8mb4_unicode_ci', 'comment' => '', 'precision' => null, 'fixed' => null],
'title' => ['type' => 'string', 'length' => 191, 'null' => false, 'default' => null, 'collate' => 'utf8mb4_unicode_ci', 'comment' => '', 'precision' => null, 'fixed' => null],
'type' => ['type' => 'string', 'length' => 200, 'null' => true, 'default' => null, 'collate' => 'utf8mb4_unicode_ci', 'comment' => '', 'precision' => null, 'fixed' => null],
'size' => ['type' => 'integer', 'length' => 11, 'unsigned' => false, 'null' => true, 'default' => null, 'comment' => '', 'precision' => null, 'autoIncrement' => null],
'created' => ['type' => 'datetime', 'length' => null, 'null' => true, 'default' => null, 'comment' => '', 'precision' => null],
Expand Down Expand Up @@ -58,7 +58,7 @@ public function init()
[
'id' => 1,
'name' => '1-my-upload.png',
'title' => null,
'title' => '1-my-upload.png',
'type' => 'image/png',
'size' => 1000000,
'user_id' => 1,
Expand All @@ -68,7 +68,7 @@ public function init()
[
'id' => 2,
'name' => '3-another-upload.jpg',
'title' => null,
'title' => '3-another-upload.jpg',
'type' => 'image/jpeg',
'size' => 50000,
'user_id' => 3,
Expand Down
2 changes: 1 addition & 1 deletion src/Controller/EntriesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,7 @@ protected function _setupCategoryChooser(CurrentUserInterface $User)
$this->set('categoryChooserTitleId', $title);
$this->set(
'categoryChooser',
$User->getCategories()->getAll('read', 'list')
$User->getCategories()->getAll('read', 'select')
);
}

Expand Down
26 changes: 21 additions & 5 deletions src/Lib/Saito/User/Categories.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@ public function __construct(CurrentUserInterface $User)
}

/**
* get all available categories to the user
*
* Get all available categories to the user in order
*
* @param string $action action
* @param string $format format
* - 'short': [id1 => 'id1', id2 => 'id2']
* - 'select': [id1 => 'title 1'] for html select
* - 'list': [['id' => <id>, 'title' => <title>], [...]] suited for JS use
* - 'select': [id1 => 'title 1'] for Cake Form Helper select
* - 'short': [id1 => 'id1', id2 => 'id2'] suited for use in queries
* @return mixed
*/
public function getAll($action, $format = 'short')
Expand All @@ -68,14 +68,30 @@ function () use ($action, $format) {
foreach ($all as $category) {
$categories[$category->get('id')] = $category->get('category');
}
$categories = $this->_filterAllowed($action, $categories);

switch ($format) {
case 'select':
break;
case 'short':
$cIds = array_keys($categories);
$categories = array_combine($cIds, $cIds);
break;
case 'list':
$cats = [];
foreach ($categories as $key => $category) {
$cats[] = ['id' => $key, 'title' => $category];
}
$categories = $cats;
break;
default:
throw new \InvalidArgumentException(
sprintf('Invalid argument %s for $format.', $format),
1567319405
);
}

return $this->_filterAllowed($action, $categories);
return $categories;
}
);
Stopwatch::stop('User\Categories::getAll()');
Expand Down
2 changes: 1 addition & 1 deletion src/Lib/version.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
$config = [
'Saito' =>
[
'v' => '5.3.0',
'v' => '5.3.1',
'saitoHomepage' => 'https://saito.siezi.com/'
]
];
Expand Down
4 changes: 0 additions & 4 deletions src/Locale/de/default.po
Original file line number Diff line number Diff line change
Expand Up @@ -575,10 +575,6 @@ msgstr ""
msgid "Category"
msgstr "Kategorie"

#: src/View/Helper/PostingHelper.php:115
msgid "error_category_empty"
msgstr "Bitte Kategorie wählen."

# msgstr "Aufrufe"
#: src/View/Helper/PostingHelper.php:137
msgid "views_headline"
Expand Down
Loading

0 comments on commit bceb3a7

Please sign in to comment.