Skip to content

Commit

Permalink
Merge branch 'release-0.10' into 0.10-multiedit
Browse files Browse the repository at this point in the history
  • Loading branch information
v1r0x authored Oct 9, 2023
2 parents 95fb283 + 22d8cff commit b420a3c
Show file tree
Hide file tree
Showing 86 changed files with 15,836 additions and 43,824 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ node_modules
### Plugins ###
thesaurex
/db
/app/Plugins/

## Created by PHPUnit/Coveralls
/build
Expand Down
67 changes: 67 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,73 @@ All notable changes to this project will be documented in this file.
### Changed
- Entity tree sorting is now accessible through ...-menu

## 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

## 0.9.9
### Fixed
- Plugin updates

## 0.9.8
No notable changes in this release

## 0.9.7
### Added
- Attribute Name and path to entity detail's link list (path is shown on hover; entity type name is shown on dot hover!)
- Reload button to _Not Found_ page
- Highlight matching strings in bibliography search
### Fixed
- Dropdown overflow in Add/Edit Bibliography Item modal
- Attribute Dependencies could not be added/updated
- Modal footer buttons on small screens
- Again: References list not visible after added a new one if it's the first literature reference added to that attribute
- Add new bibliography items from file import to list
- Prevent to add already added attributes to entity types
- Non-translated toast text shown when references tab in _Entity Detail_ panel can not be opened
- Empty dropdowns for newly created and added attributes in _Entity Detail_ panel
- Save entity with values set for a former empty _Entity (Multiple Choice)_ attribute

## 0.9.6
### Added
- Info modal in references tab to view all information from an literature reference
Expand Down
21 changes: 21 additions & 0 deletions app/Attribute.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,27 @@ public function getActivitylogOptions() : LogOptions
->logOnlyDirty();
}

public function getSelection() {
switch ($this->datatype) {
case 'string-sc':
case 'string-mc':
case 'epoch':
return ThConcept::getChildren($this->thesaurus_root_url, $this->recursive);
case 'table':
// Only string-sc is allowed in tables
$columns = Attribute::where('parent_id', $this->id)
->where('datatype', 'string-sc')
->get();
$selection = [];
foreach ($columns as $c) {
$selection[$c->id] = ThConcept::getChildren($c->thesaurus_root_url, $c->recursive);
}
return $selection;
default:
return null;
}
}

public function children() {
return $this->hasMany('App\Attribute', 'parent_id');
}
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
3 changes: 3 additions & 0 deletions app/Entity.php
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@ public function getAttributeLinksAttribute() {
$query->whereJsonContains('json_val', $this->id)
->whereIn('attribute_id', $entityMcAttributes);
})
->with('attribute')
->get();
$entities = [];
foreach($links as $link) {
Expand All @@ -293,6 +294,8 @@ public function getAttributeLinksAttribute() {
'id' => $entity->id,
'name' => $entity->name,
'entity_type_id' => $entity->entity_type_id,
'attribute_url' => $link->attribute->thesaurus_url,
'path' => array_reverse($entity->parentNames),
];
}
return $entities;
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
24 changes: 17 additions & 7 deletions app/Http/Controllers/BibliographyController.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ public function importBibtex(Request $request) {
], 400);
}
$entries = $listener->export();
$newEntries = [];
$newChangedEntries = [];
foreach($entries as $entry) {
$insArray = array_intersect_key($entry, Bibliography::patchRules);
// set citation key if none is present
Expand All @@ -157,10 +157,18 @@ public function importBibtex(Request $request) {
$insArray
);
if($bibliography->wasRecentlyCreated) {
$newEntries[] = Bibliography::find($bibliography->id);
$newChangedEntries[] = [
'entry' => Bibliography::find($bibliography->id),
'added' => true,
];
} else if($bibliography->wasChanged()) {
$newChangedEntries[] = [
'entry' => Bibliography::find($bibliography->id),
'added' => false,
];
}
}
return response()->json($newEntries, 201);
return response()->json($newChangedEntries, 201);
}

// PATCH
Expand All @@ -175,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 @@ -186,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 @@ -196,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 @@ -219,6 +230,7 @@ public function deleteItem($id) {
], 400);
}

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

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

Storage::delete($item->file);
$item->file = null;
$item->save();
$item->deleteFile();
return response()->json(null, 204);
}
}
Loading

0 comments on commit b420a3c

Please sign in to comment.