fixes date timezone bug
This commit is contained in:
38
db/migrations/1712334451_updated_summit_logs.go
Normal file
38
db/migrations/1712334451_updated_summit_logs.go
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
package migrations
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/pocketbase/dbx"
|
||||||
|
"github.com/pocketbase/pocketbase/daos"
|
||||||
|
m "github.com/pocketbase/pocketbase/migrations"
|
||||||
|
"github.com/pocketbase/pocketbase/tools/types"
|
||||||
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
m.Register(func(db dbx.Builder) error {
|
||||||
|
dao := daos.New(db);
|
||||||
|
|
||||||
|
collection, err := dao.FindCollectionByNameOrId("dd2l9a4vxpy2ni8")
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
collection.ListRule = types.Pointer("(@request.auth.id != \"\" && @collection.trails.summit_logs.id ?= id && @collection.trails.author ?= @request.auth.id) || (@collection.trails.summit_logs.id ?= id && @collection.trails.public = true)")
|
||||||
|
|
||||||
|
collection.ViewRule = types.Pointer("(@request.auth.id != \"\" && @collection.trails.summit_logs.id ?= id && @collection.trails.author ?= @request.auth.id) || (@collection.trails.summit_logs.id ?= id && @collection.trails.public = true)")
|
||||||
|
|
||||||
|
return dao.SaveCollection(collection)
|
||||||
|
}, func(db dbx.Builder) error {
|
||||||
|
dao := daos.New(db);
|
||||||
|
|
||||||
|
collection, err := dao.FindCollectionByNameOrId("dd2l9a4vxpy2ni8")
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
collection.ListRule = types.Pointer("(@request.auth.id != \"\" && @collection.trails.summit_logs.id ?= id && @collection.trails.author ?= @request.auth.id) || @collection.trails.summit_logs.id ?= id && @collection.trails.public = true")
|
||||||
|
|
||||||
|
collection.ViewRule = types.Pointer("(@request.auth.id != \"\" && @collection.trails.summit_logs.id ?= id && @collection.trails.author ?= @request.auth.id) || @collection.trails.summit_logs.id ?= id && @collection.trails.public = true")
|
||||||
|
|
||||||
|
return dao.SaveCollection(collection)
|
||||||
|
})
|
||||||
|
}
|
||||||
38
db/migrations/1712335100_updated_summit_logs.go
Normal file
38
db/migrations/1712335100_updated_summit_logs.go
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
package migrations
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/pocketbase/dbx"
|
||||||
|
"github.com/pocketbase/pocketbase/daos"
|
||||||
|
m "github.com/pocketbase/pocketbase/migrations"
|
||||||
|
"github.com/pocketbase/pocketbase/tools/types"
|
||||||
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
m.Register(func(db dbx.Builder) error {
|
||||||
|
dao := daos.New(db);
|
||||||
|
|
||||||
|
collection, err := dao.FindCollectionByNameOrId("dd2l9a4vxpy2ni8")
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
collection.UpdateRule = types.Pointer("@request.auth.id != \"\" && @collection.trails.summit_logs.id ?= id && (@collection.trails.author ?= @request.auth.id)")
|
||||||
|
|
||||||
|
collection.DeleteRule = types.Pointer("@request.auth.id != \"\" && @collection.trails.summit_logs.id ?= id && (@collection.trails.author ?= @request.auth.id)")
|
||||||
|
|
||||||
|
return dao.SaveCollection(collection)
|
||||||
|
}, func(db dbx.Builder) error {
|
||||||
|
dao := daos.New(db);
|
||||||
|
|
||||||
|
collection, err := dao.FindCollectionByNameOrId("dd2l9a4vxpy2ni8")
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
collection.UpdateRule = types.Pointer("@request.auth.id != \"\" && @collection.trails.summit_logs.id ?= id && (@collection.trails.author = @request.auth.id)")
|
||||||
|
|
||||||
|
collection.DeleteRule = types.Pointer("@request.auth.id != \"\" && @collection.trails.summit_logs.id ?= id && (@collection.trails.author = @request.auth.id)")
|
||||||
|
|
||||||
|
return dao.SaveCollection(collection)
|
||||||
|
})
|
||||||
|
}
|
||||||
@@ -19,6 +19,7 @@
|
|||||||
month: "2-digit",
|
month: "2-digit",
|
||||||
day: "2-digit",
|
day: "2-digit",
|
||||||
year: "numeric",
|
year: "numeric",
|
||||||
|
timeZone: "UTC",
|
||||||
})}
|
})}
|
||||||
</h5>
|
</h5>
|
||||||
|
|
||||||
|
|||||||
@@ -44,6 +44,7 @@
|
|||||||
month: "long",
|
month: "long",
|
||||||
day: "2-digit",
|
day: "2-digit",
|
||||||
year: "numeric",
|
year: "numeric",
|
||||||
|
timeZone: 'UTC'
|
||||||
})}
|
})}
|
||||||
</p>
|
</p>
|
||||||
{/if}
|
{/if}
|
||||||
|
|||||||
@@ -35,6 +35,7 @@
|
|||||||
month: "long",
|
month: "long",
|
||||||
day: "2-digit",
|
day: "2-digit",
|
||||||
year: "numeric",
|
year: "numeric",
|
||||||
|
timeZone: 'UTC'
|
||||||
})}
|
})}
|
||||||
</p>
|
</p>
|
||||||
{/if}
|
{/if}
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
"change": "Ändern",
|
"change": "Ändern",
|
||||||
"changelog": "Changelog",
|
"changelog": "Changelog",
|
||||||
"chinese": "Chinesisch (vereinfacht)",
|
"chinese": "Chinesisch (vereinfacht)",
|
||||||
"comment": "{n, Plural, =1 {Kommentar} other {Kommentare}}",
|
"comment": "{n, plural, =1 {Kommentar} other {Kommentare}}",
|
||||||
"completed": "Abgeschlossen",
|
"completed": "Abgeschlossen",
|
||||||
"completion-status": "Abschlussstatus",
|
"completion-status": "Abschlussstatus",
|
||||||
"contribute": "Mitwirken",
|
"contribute": "Mitwirken",
|
||||||
|
|||||||
@@ -8,9 +8,15 @@ export async function GET(event: RequestEvent) {
|
|||||||
try {
|
try {
|
||||||
const r = await pb.collection('trails')
|
const r = await pb.collection('trails')
|
||||||
.getOne<Trail>(event.params.id as string, { expand: expand ?? "" })
|
.getOne<Trail>(event.params.id as string, { expand: expand ?? "" })
|
||||||
|
|
||||||
|
// remove time from dates
|
||||||
|
r.date = r.date?.substring(0, 10) ?? ""
|
||||||
|
for (const log of r.expand?.summit_logs ?? []) {
|
||||||
|
log.date = log.date.substring(0, 10)
|
||||||
|
}
|
||||||
return json(r)
|
return json(r)
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
throw error(e.status, e);
|
throw error(e.status || 500, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -263,12 +263,12 @@
|
|||||||
$form.duration = Math.round(
|
$form.duration = Math.round(
|
||||||
e.target.get_total_time() / 1000 / 60,
|
e.target.get_total_time() / 1000 / 60,
|
||||||
);
|
);
|
||||||
if ($form.duration) {
|
if ($form.duration && !$form.date) {
|
||||||
$form.date = e.target
|
$form.date = e.target
|
||||||
.get_start_time()
|
.get_start_time()
|
||||||
.toISOString()
|
.toISOString()
|
||||||
.substring(0, 10);
|
.substring(0, 10);
|
||||||
} else {
|
} else if(!$form.date) {
|
||||||
$form.date = new Date().toISOString().substring(0, 10);
|
$form.date = new Date().toISOString().substring(0, 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -475,11 +475,12 @@
|
|||||||
on:change={handleFileSelection}
|
on:change={handleFileSelection}
|
||||||
/>
|
/>
|
||||||
<hr class="border-separator" />
|
<hr class="border-separator" />
|
||||||
<div class="flex gap-x-4">
|
<div class="flex gap-x-2">
|
||||||
<h3 class="text-xl font-semibold">{$_("basic-info")}</h3>
|
<h3 class="text-xl font-semibold">{$_("basic-info")}</h3>
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
class="btn-icon"
|
class="btn-icon"
|
||||||
|
style="font-size: 0.9rem"
|
||||||
on:click={() => (editingBasicInfo = !editingBasicInfo)}
|
on:click={() => (editingBasicInfo = !editingBasicInfo)}
|
||||||
><i class="fa fa-{editingBasicInfo ? 'check' : 'pen'}"
|
><i class="fa fa-{editingBasicInfo ? 'check' : 'pen'}"
|
||||||
></i></button
|
></i></button
|
||||||
@@ -554,7 +555,7 @@
|
|||||||
error={$errors.location}
|
error={$errors.location}
|
||||||
bind:value={$form.location}
|
bind:value={$form.location}
|
||||||
></TextField>
|
></TextField>
|
||||||
<Datepicker label="Date" bind:value={$form.date}></Datepicker>
|
<Datepicker label={$_("date")} bind:value={$form.date}></Datepicker>
|
||||||
<Textarea
|
<Textarea
|
||||||
name="description"
|
name="description"
|
||||||
label={$_("describe-your-trail")}
|
label={$_("describe-your-trail")}
|
||||||
|
|||||||
Reference in New Issue
Block a user