Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some fixes #3103

Merged
merged 4 commits into from
Oct 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ All notable changes to this project will be documented in this file.
### Fixes
- Fixed granting admin rights to shares
- Fixed a bug, where exports were prevented
- Fixed a visually bug when using Nextcloud's Dark Mode
### New
- Reveal hidden voters if hidden in case of performance concerns
- Support better readability of vote page
Expand Down
119 changes: 119 additions & 0 deletions lib/Migration/Version050400Date20231011211202.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
<?php
/**
* @copyright Copyright (c) 2021 René Gieling <github@dartcafe.de>
*
* @author René Gieling <github@dartcafe.de>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/

namespace OCA\Polls\Migration;

use Doctrine\DBAL\Types\Type;
use OCA\Polls\Db\TableManager;
use OCP\DB\ISchemaWrapper;
use OCP\IDBConnection;
use OCP\Migration\IOutput;
use OCP\Migration\SimpleMigrationStep;

/**
* Installation class for the polls app.
* Initial db creation
* Changed class naming: Version[jjmmpp]Date[YYYYMMDDHHMMSS]
* Version: jj = major version, mm = minor, pp = patch
*/
class Version050400Date20231011211202 extends SimpleMigrationStep {
private ISchemaWrapper $schema;

public function __construct(
private TableManager $tableManager,
private IDBConnection $connection,
) {
}

/**
* $schemaClosure The `\Closure` returns a `ISchemaWrapper`
*/
public function changeSchema(IOutput $output, \Closure $schemaClosure, array $options) {
$this->schema = $schemaClosure();
$messages = $this->createTables();

foreach ($messages as $message) {
$output->info('Polls - ' . $message);
};

return $this->schema;
}

/**
* @return string[]
*
* @psalm-return non-empty-list<string>
*/
public function createTable(string $tableName, array $columns): array {
$messages = [];

if ($this->schema->hasTable($tableName)) {
$table = $this->schema->getTable($tableName);
$messages[] = 'Validating table ' . $table->getName();
$tableCreated = false;
} else {
$table = $this->schema->createTable($tableName);
$tableCreated = true;
$messages[] = 'Creating table ' . $table->getName();
}

foreach ($columns as $columnName => $columnDefinition) {
if ($table->hasColumn($columnName)) {
$column = $table->getColumn($columnName);
if ($column->getType()->getName() !== $columnDefinition['type']) {
$messages[] = 'Migrated type of ' . $table->getName() . '[\'' . $columnName . '\'] from ' . $column->getType()->getName() . ' to ' . $columnDefinition['type'];
$column->setType(Type::getType($columnDefinition['type']));
}
$column->setOptions($columnDefinition['options']);

// force change to current options definition
$table->changeColumn($columnName, $columnDefinition['options']);
} else {
$table->addColumn($columnName, $columnDefinition['type'], $columnDefinition['options']);
$messages[] = 'Added ' . $table->getName() . ', ' . $columnName . ' (' . $columnDefinition['type'] . ')';
}
}

if ($tableCreated) {
$table->setPrimaryKey(['id']);
}
return $messages;
}

/**
* @return string[]
*
* @psalm-return non-empty-list<string>
*/
public function createTables(): array {
$messages = [];

foreach (TableSchema::TABLES as $tableName => $columns) {
$messages = array_merge($messages, $this->createTable($tableName, $columns));
}
return $messages;
}



}
9 changes: 8 additions & 1 deletion src/js/assets/scss/colors.scss
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@
--color-polls-background-maybe: #fcf7e1;
}

body#body-public,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dartcafe This doesn't just match in dark mode, but always.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah damned. I did not test it in public polls.

[data-theme-dark],
[data-theme-dark-highcontrast] {
--color-polls-background-yes: #2e4600;
--color-polls-background-no: #4d0d00;
--color-polls-background-maybe: #665600;
}

@media (prefers-color-scheme: dark) {
body#body-public,
[data-theme-default] {
Expand All @@ -17,4 +25,3 @@
}

}