Skip to content

Commit

Permalink
Merge branch 'release-0.10' into 0.10-external-access
Browse files Browse the repository at this point in the history
Signed-off-by: Vinzenz Rosenkranz <[email protected]>
  • Loading branch information
v1r0x committed Aug 10, 2023
2 parents 94c6018 + 6d045b0 commit 5ab7629
Show file tree
Hide file tree
Showing 55 changed files with 14,543 additions and 41,308 deletions.
40 changes: 40 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,47 @@
# Changelog
All notable changes to this project will be documented in this file.

## 0.9.14
### Added
- Changelog Viewer
- Added to _Plugins_ Settings (if an update is available)
- System attributes
- Attribute Group Separator
- attributes can now be sorted into self-defined groups, shown as tabs in _Main View_
- Option to set the width of entity attributes (50% or 100% (default))
### Fixed
- File types to attach to bibliography items
- Deleting files attached to bibliography items
- Enable button if only file is added/removed from bibliography item
- Modal Backdrop
### Changed
- _Attach file_ button text in _Bibliography Item_ modal to make clear that _Drag & Drop_ is also possible
- Update Laravel to v10
- Update several dependencies
- Replaced markdown renderer dependency
- Moved _Add Entitytype_ button to the header
- Several UI- and Bug-Fixes

## 0.9.13
### Fixed
- Adding/Editing bibliography entries of a type where a field is only mandatory if another field is not set

## 0.9.12
### Fixed
- App not useable when a notifications with a reference to a deleted entity exists

## 0.9.11
### Fixed
- Error on page access with no installed plugins (because Plugin directory is missing)

## 0.9.10
### Added
- Background to column section in _Add Attribute_ modal to better distinguish it from the main section
### Fixed
- Reset label search after column added to table datatype in _Add Attribute_ modal
- Reset column values after new row is added in _Entity Detail_ form
- Preview for _table_ datatype
- Dropdowns for columns of newly added _table_ attribute only visible after page reload
### Changed
- Attributes in entity detail's link list are now grouped by linked entity

Expand Down
17 changes: 13 additions & 4 deletions app/Bibliography.php
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ public function fieldsFromRequest($request, $user) {
}
} else {
if(
(!isset($this->{$man}) || empty($this->{$man})) ||
(!isset($this->{$man}) || empty($this->{$man})) &&
(!isset($this->{$manType}) || empty($this->{$manType}))
) {
return false;
Expand Down Expand Up @@ -356,9 +356,7 @@ public static function computeCitationKey($fields) {
}

public function uploadFile($file) {
if(isset($this->file) && Storage::exists($this->file)) {
Storage::delete($this->file);
}
$this->deleteFile(true);

$filename = $this->id . "_" . $file->getClientOriginalName();
return $file->storeAs(
Expand All @@ -367,6 +365,17 @@ public function uploadFile($file) {
);
}

public function deleteFile(bool $fromStorageOnly = false) {
if(isset($this->file) && Storage::exists($this->file)) {
Storage::delete($this->file);
}

if(!$fromStorageOnly) {
$this->file = null;
$this->save();
}
}

public function user() {
return $this->belongsTo('App\User');
}
Expand Down
1 change: 1 addition & 0 deletions app/EntityAttributePivot.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@ class EntityAttributePivot extends Pivot

protected $casts = [
'depends_on' => 'array',
'metadata' => 'array',
];
}
2 changes: 1 addition & 1 deletion app/EntityType.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function entities() {
}

public function attributes() {
return $this->belongsToMany('App\Attribute', 'entity_attributes')->withPivot(['position', 'depends_on'])->orderBy('entity_attributes.position')->using(EntityAttributePivot::class);
return $this->belongsToMany('App\Attribute', 'entity_attributes')->withPivot(['position', 'depends_on', 'metadata', 'id'])->orderBy('entity_attributes.position')->using(EntityAttributePivot::class);
}

public function sub_entity_types() {
Expand Down
10 changes: 6 additions & 4 deletions app/Http/Controllers/BibliographyController.php
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ public function updateItem(Request $request, $id) {
$this->validate($request, [
'type' => 'alpha|bibtex_type',
'file' => 'file',
'delete_file' => 'boolean_string',
]);

try {
Expand All @@ -194,7 +195,7 @@ public function updateItem(Request $request, $id) {
}
$file = $request->file('file');

$success = $bib->fieldsFromRequest($request->except('file'), $user);
$success = $bib->fieldsFromRequest($request->except(['file', 'delete_file']), $user);
if(!$success) {
return response()->json([
'error' => __('At least one required field is not set')
Expand All @@ -204,6 +205,8 @@ public function updateItem(Request $request, $id) {
$bib->file = $bib->uploadFile($file);
$bib->user_id = $user->id;
$bib->save();
} else if($request->has('delete_file') && sp_parse_boolean($request->get('delete_file'))) {
$bib->deleteFile();
}
$bib = Bibliography::find($bib->id);

Expand All @@ -227,6 +230,7 @@ public function deleteItem($id) {
], 400);
}

$bib->deleteFile();
$bib->delete();

return response()->json(null, 204);
Expand All @@ -248,9 +252,7 @@ public function deleteItemFile($id) {
], 400);
}

Storage::delete($item->file);
$item->file = null;
$item->save();
$item->deleteFile();
return response()->json(null, 204);
}
}
54 changes: 45 additions & 9 deletions app/Http/Controllers/EditorController.php
Original file line number Diff line number Diff line change
Expand Up @@ -683,6 +683,43 @@ public function patchDependency(Request $request, $etid, $aid) {
return response()->json($entityAttribute->depends_on, 200);
}

public function patchSystemAttribute(Request $request, $id) {
$user = auth()->user();
if(!$user->can('entity_type_write')) {
return response()->json([
'error' => __('You do not have the permission to edit attribute names')
], 403);
}
$this->validate($request, [
'title' => 'string|required_without:width',
'width' => 'integer|required_without:title',
]);

try {
$entityAttribute = EntityAttribute::findOrFail($id);
} catch(ModelNotFoundException $e) {
return response()->json([
'error' => __('Entity Attribute not found')
], 400);
}

$metadata = json_decode($entityAttribute->metadata) ?? new \stdClass();

if($request->has('title')) {
$title = $request->get('title');
$metadata->title = $title;
}
if($request->has('width')) {
$width = $request->get('width');
$metadata->width = $width;
}

$entityAttribute->metadata = json_encode($metadata);
$entityAttribute->save();

return response()->json($metadata, 200);
}

// DELETE

public function deleteEntityType($id) {
Expand Down Expand Up @@ -724,26 +761,25 @@ public function deleteAttribute($id) {
return response()->json(null, 204);
}

public function removeAttributeFromEntityType($etid, $aid) {
public function removeAttributeFromEntityType($id) {
$user = auth()->user();
if(!$user->can('entity_type_write')) {
return response()->json([
'error' => __('You do not have the permission to remove attributes from entity types')
], 403);
}
$ca = EntityAttribute::where([
['attribute_id', '=', $aid],
['entity_type_id', '=', $etid]
])->first();

if($ca === null){
try {
$ea = EntityAttribute::findOrFail($id);
} catch(ModelNotFoundException $e) {
return response()->json([
'error' => __('Entity Attribute not found')
], 400);
}

$pos = $ca->position;
$ca->delete();
$pos = $ea->position;
$aid = $ea->attribute_id;
$etid = $ea->entity_type_id;
$ea->delete();

$successors = EntityAttribute::where([
['position', '>', $pos],
Expand Down
1 change: 1 addition & 0 deletions app/Http/Controllers/PluginController.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public function getPlugins(Request $request) {

foreach($plugins as $plugin) {
$plugin->metadata = $plugin->getMetadata();
$plugin->changelog = $plugin->getChangelog();
}

return response()->json($plugins);
Expand Down
10 changes: 10 additions & 0 deletions app/Notification.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Notification extends Model
{
public $incrementing = false;
}
3 changes: 3 additions & 0 deletions app/Observers/EntityObserver.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace App\Observers;

use App\Entity;
use App\Notification;
use App\Notifications\EntityUpdated;
use App\User;
use Illuminate\Database\Eloquent\ModelNotFoundException;
Expand Down Expand Up @@ -37,5 +38,7 @@ public function saving(Entity $entity)
public function deleted(Entity $entity)
{
Entity::where('root_entity_id', $entity->root_entity_id)->where('rank', '>', $entity->rank)->decrement('rank');
// Delete notifications where the deleted entity is referenced
Notification::whereRaw("(data::json->>'resource')::json->>'id' = ?", [$entity->id])->delete();
}
}
10 changes: 10 additions & 0 deletions app/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,16 @@ public function getMetadata() {
}
}

public function getChangelog($since = null) {
$changelog = Str::finish(base_path("app/Plugins/$this->name"), '/') . 'CHANGELOG.md';
if(!File::isFile($changelog)) return '';
$changes = file_get_contents($changelog);
// if(isset($since)) {

// }
return $changes;
}

public static function updateOrCreateFromInfo(array $info) : Plugin {
$id = $info['name'];
$plugin = self::where('name', $id)->first();
Expand Down
Empty file added app/Plugins/.gitignore
Empty file.
2 changes: 0 additions & 2 deletions app/Providers/AuthServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ class AuthServiceProvider extends ServiceProvider
*/
public function boot()
{
$this->registerPolicies();

//
}
}
2 changes: 1 addition & 1 deletion app/ThConcept.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public static function getMap($lang = 'en') {
)
SELECT id, concept_url, is_top_concept, label, language_id, short_name
FROM summary s
WHERE s.rk = 1"));
WHERE s.rk = 1")->getValue(DB::connection()->getQueryGrammar()));

$conceptMap = [];

Expand Down
28 changes: 14 additions & 14 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,35 +8,35 @@
"license": "MIT",
"type": "project",
"require": {
"php": ">=8.0.2",
"php": ">=8.1.0",
"bosnadev/database": "dev-master as 0.21.1",
"guzzlehttp/guzzle": "^7.4",
"laravel-lang/lang": "^11.0.15",
"laravel/framework": "^9.0",
"laravel-lang/lang": "^12.21.1",
"laravel/framework": "^10.0",
"laravel/tinker": "~2.0",
"laravel/ui": "^3.0",
"laravel/ui": "^4.2",
"lsolesen/pel": "^0.9.12",
"mstaack/laravel-postgis": "^5.4",
"mstaack/laravel-postgis": "^6.1",
"nicolaslopezj/searchable": "^1.13.0",
"php-open-source-saver/jwt-auth": "^1.4.2",
"php-open-source-saver/jwt-auth": "^2.1.0",
"phpoffice/phppresentation": "^1.0.0",
"phpoffice/phpspreadsheet": "^1.24.1",
"phpoffice/phpword": "^0.18.3",
"phpoffice/phpspreadsheet": "^1.28.0",
"phpoffice/phpword": "^1.0.0",
"renanbr/bibtex-parser": "^2.1.2",
"spatie/laravel-activitylog": "^4.5.3",
"spatie/laravel-ignition": "^1.0",
"spatie/laravel-permission": "^5.5.5",
"spatie/laravel-activitylog": "^4.7.3",
"spatie/laravel-ignition": "^2.1",
"spatie/laravel-permission": "^5.10.1",
"spatie/laravel-searchable": "^1.11",
"tecnickcom/tcpdf": "^6.5.0",
"wapmorgan/unified-archive": "^1.1.7"
"tecnickcom/tcpdf": "^6.6.2",
"wapmorgan/unified-archive": "^1.1.10"
},
"require-dev": {
"beyondcode/laravel-dump-server": "^1.0",
"dms/phpunit-arraysubset-asserts": "^0.2.1",
"filp/whoops": "~2.0",
"fzaninotto/faker": "~1.4",
"mockery/mockery": "~1.0",
"nunomaduro/collision": "^6.1",
"nunomaduro/collision": "^7.0",
"phpunit/phpunit": "~9.0"
},
"autoload": {
Expand Down
Loading

0 comments on commit 5ab7629

Please sign in to comment.