Skip to content

Commit 002bae3

Browse files
authored
Merge pull request #1290 from KodeStar/feature/add_columns
Add alternate tag types
2 parents d184427 + b7c0fd2 commit 002bae3

11 files changed

Lines changed: 141 additions & 18 deletions

File tree

app/Http/Controllers/ItemController.php

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,32 @@ public function __construct()
3535
*/
3636
public function dash(): View
3737
{
38-
$data['apps'] = Item::whereHas('parents', function ($query) {
39-
$query->where('id', 0);
40-
})->orWhere('type', 1)->pinned()->orderBy('order', 'asc')->get();
38+
$treat_tags_as = \App\Setting::fetch('treat_tags_as');
4139

42-
$data['all_apps'] = Item::whereHas('parents', function ($query) {
43-
$query->where('id', 0);
44-
})->orWhere('type', 1)->orderBy('order', 'asc')->get();
40+
$data["treat_tags_as"] = $treat_tags_as;
41+
42+
if ($treat_tags_as == 'categories') {
43+
$data['categories'] = Item::whereHas('children')->with('children', function ($query) {
44+
$query->pinned()->orderBy('order', 'asc');
45+
})->pinned()->orderBy('order', 'asc')->get();
46+
47+
} elseif ($treat_tags_as == 'tags') {
48+
$data['apps'] = Item::with('parents')->where('type', 0)->pinned()->orderBy('order', 'asc')->get();
49+
$data['all_apps'] = Item::where('type', 0)->orderBy('order', 'asc')->get();
50+
$data['taglist'] = Item::where('type', 1)->pinned()->orderBy('order', 'asc')->get();
51+
} else {
52+
53+
$data['apps'] = Item::whereHas('parents', function ($query) {
54+
$query->where('id', 0);
55+
})->orWhere('type', 1)->pinned()->orderBy('order', 'asc')->get();
56+
57+
$data['all_apps'] = Item::whereHas('parents', function ($query) {
58+
$query->where('id', 0);
59+
})->orWhere('type', 1)->orderBy('order', 'asc')->get();
60+
}
4561

4662
//$data['all_apps'] = Item::doesntHave('parents')->get();
47-
//die(print_r($data['apps']));
63+
// die(print_r($data));
4864
return view('welcome', $data);
4965
}
5066

database/seeders/SettingsSeeder.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,5 +327,28 @@ public function run(): void
327327
$app->parents()->attach(0);
328328
}
329329
}
330+
331+
$tag_options = json_encode([
332+
'folders' => 'app.settings.folders',
333+
'tags' => 'app.settings.tags',
334+
'categories' => 'app.settings.categories',
335+
]);
336+
337+
if (! $setting = Setting::find(14)) {
338+
$setting = new Setting;
339+
$setting->id = 14;
340+
$setting->group_id = 2;
341+
$setting->key = 'treat_tags_as';
342+
$setting->type = 'select';
343+
$setting->options = $tag_options;
344+
$setting->value = 'folders';
345+
$setting->label = 'app.settings.treat_tags_as';
346+
$setting->save();
347+
} else {
348+
$setting->options = $tag_options;
349+
$setting->label = 'app.settings.treat_tags_as';
350+
$setting->save();
351+
}
352+
330353
}
331354
}

lang/en/app.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@
2828
'settings.view' => 'View',
2929
'settings.custom_css' => 'Custom CSS',
3030
'settings.custom_js' => 'Custom JavaScript',
31+
'settings.treat_tags_as' => 'Treat Tags As:',
32+
'settings.folders' => 'Folders',
33+
'settings.tags' => 'Tags',
34+
'settings.categories' => 'Categories',
3135
'options.none' => '- not set -',
3236
'options.google' => 'Google',
3337
'options.ddg' => 'DuckDuckGo',

public/css/app.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/js/app.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/mix-manifest.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

resources/assets/js/app.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,16 @@ $.when($.ready).then(() => {
171171
}, 350);
172172
}
173173
})
174+
.on("click", ".tag", (e) => {
175+
e.preventDefault();
176+
const tag = $(e.target).data("tag");
177+
$("#taglist .tag").removeClass("current");
178+
$(e.target).addClass("current");
179+
$("#sortable .item-container").show();
180+
if (tag !== "all") {
181+
$("#sortable .item-container:not(." + tag + ")").hide();
182+
}
183+
})
174184
.on("click", "#add-item, #pin-item", (e) => {
175185
e.preventDefault();
176186
const app = $("#app");

resources/assets/sass/_app.scss

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,22 @@ body {
180180
list-style: none;
181181
margin: 0;
182182
}
183+
#sortable.categories {
184+
align-items: flex-start;
185+
.category {
186+
margin:10px;
187+
background-color: #00000038;
188+
border-radius: 10px;
189+
> .title {
190+
padding: 20px 20px 0;
191+
192+
a {
193+
color: white;
194+
text-decoration: none;
195+
}
196+
}
197+
}
198+
}
183199
}
184200
#config-buttons {
185201
position: fixed;
@@ -279,6 +295,9 @@ body {
279295
z-index: 1;
280296
}
281297
}
298+
.categorytitle {
299+
color: #fff!important;
300+
}
282301
.tooltip {
283302
padding: 25px;
284303
border-radius: 5px;
@@ -294,13 +313,32 @@ body {
294313
opacity: 0;
295314
transform: translateY(-20px);
296315
transition: all 0.3s;
316+
pointer-events: none;
297317
&.active {
298318
transform: translateY(0);
299319
opacity: 1;
300320
z-index: 4;
301321
}
302322
}
303-
323+
.taglist {
324+
display: flex;
325+
flex-wrap: wrap;
326+
gap: 5px;
327+
.tag {
328+
padding: 10px 20px;
329+
background: rgba(0, 0, 0, 0.608);
330+
border-radius: 6px;
331+
font-size: 12px;
332+
cursor: pointer;
333+
opacity: 0.6;
334+
&.current {
335+
opacity: 1;
336+
}
337+
&:hover:not(.current) {
338+
opacity: 0.8;
339+
}
340+
}
341+
}
304342
.tile-actions {
305343
position: absolute;
306344
top: 0px;
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
$treat_tags_as = \App\Setting::fetch('treat_tags_as');
3+
?>
4+
@if( $treat_tags_as == 'tags')
5+
@if($taglist->first())
6+
<div id="taglist" class="taglist">
7+
<div class="tag white current" data-tag="all">All</div>
8+
@foreach($taglist as $tag)
9+
<div class="tag link{{ title_color($tag->colour) }}" style="background-color: {{ $tag->colour }}" data-tag="tag-{{ $tag->url }}">{{ $tag->title }}</div>
10+
@endforeach
11+
</div>
12+
@endif
13+
@endif

resources/views/sortable.blade.php

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,24 @@
1-
<div id="sortable">
2-
@foreach($apps as $app)
3-
@include('item')
4-
@endforeach
5-
@include('add')
1+
<div id="sortable" class="{{ $treat_tags_as ?? '' }}">
2+
@if(isset($treat_tags_as) && $treat_tags_as == 'categories')
3+
4+
@foreach($categories as $category)
5+
<?php $apps = $category->children; ?>
6+
<div class="category item-container" data-name="{{ $category->title }}" data-id="{{ $category->id }}">
7+
<div class="title"><a href="{{ $category->link }}" style="{{ $category->colour ? 'color: ' . $category->colour .';' : '' }}">{{ $category->title }}</a></div>
8+
@foreach($apps as $app)
9+
@include('item')
10+
@endforeach
11+
</div>
12+
@endforeach
13+
14+
15+
@else
16+
17+
@foreach($apps as $app)
18+
@include('item')
19+
@endforeach
20+
@include('add')
21+
@endif
22+
23+
624
</div>

0 commit comments

Comments
 (0)