Skip to content

Commit

Permalink
Move objtype and id at base and change object level. Base and change …
Browse files Browse the repository at this point in the history
…could be distinct objects now
  • Loading branch information
frodrigo committed Aug 12, 2024
1 parent 4a29238 commit 90803de
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 72 deletions.
131 changes: 61 additions & 70 deletions components/LogItem.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<script setup lang="ts">
import LazyComponent from 'v-lazy-component'
import _ from 'underscore'
import type { Log, ObjType } from '~/libs/types'
import { objTypeFull } from '~/libs/types'
Expand All @@ -16,29 +17,34 @@ const logSorted = computed(() => {
function objtypeFull(objtype: ObjType) {
return objTypeFull(objtype)
}
function uniqHistoryIds(log: Log) {
return _.uniq(
_.compact([log.base, log.change])
.map((object) => ({ objtype: object.objtype, id: object.id })),
(object) => `${object.objtype}${object.id}`,
)
}
</script>

<template>
<el-card shadow="never">
<template #header>
<div class="card-header">
<span>
<a
:href="`https://www.openstreetmap.org/${objtypeFull(log.objtype)}/${log.id}/history`"
target="_blank"
>
{{ log.objtype }}{{ log.id }}
</a>
-
{{ log.base?.tags.name || log.change.tags.name }}
</span>
<template v-for="object in uniqHistoryIds(log)">
<span v-if="object" :key="`${object.objtype}${object.id}`">
<a
:href="`https://www.openstreetmap.org/${objtypeFull(object.objtype)}/${object.id}/history`"
target="_blank"
>
{{ object.objtype }}{{ object.id }}
</a>
-
{{ log.base?.tags.name || log.change.tags.name }}
</span>
</template>
<span v-if="!log.base">
<el-tag
type="success"
size="small"
:disable-transitions="true"
class="item"
>
<el-tag type="success" size="small" :disable-transitions="true" class="item">
{{ $t('logs.created') }}
</el-tag>
</span>
Expand All @@ -56,20 +62,11 @@ function objtypeFull(objtype: ObjType) {
<el-tag
v-for="text in [
...new Set(log.matches.map((m) => m.user_groups).flat()),
].sort()"
:key="text"
size="small"
class="item"
].sort()" :key="text" size="small" class="item"
>
📌 {{ text }}
</el-tag>
<el-tag
v-for="match in logSorted"
:key="match.selectors.join(';')"
size="small"
type="warning"
class="item"
>
<el-tag v-for="match in logSorted" :key="match.selectors.join(';')" size="small" type="warning" class="item">
<div>
🏷️ {{ $i18nHash(match.name) }}
<br v-if="$i18nHash(match.name) !== undefined" />
Expand All @@ -80,51 +77,45 @@ function objtypeFull(objtype: ObjType) {
</div>
</el-tag>
</span>
<el-button-group>
<el-button
tag="a"
size="small"
:href="`https://www.openstreetmap.org/edit?editor=id&${objtypeFull(
log.objtype,
)}=${log.id}`"
target="_blank"
>
OSM iD
</el-button>
<template v-for="object in uniqHistoryIds(log)">
<el-button-group v-if="object" :key="`${object.objtype}${object.id}`">
<el-button
tag="a" size="small" :href="`https://www.openstreetmap.org/edit?editor=id&${objtypeFull(
object.objtype,
)}=${object.id}`" target="_blank"
>
OSM iD
</el-button>

<el-button
tag="a"
size="small"
:href="`http://127.0.0.1:8111/load_object?objects=${log.objtype}${log.id}`"
target="hidden_josm_target"
>
JOSM
</el-button>
<el-button
tag="a" size="small"
:href="`http://127.0.0.1:8111/load_object?objects=${object.objtype}${object.id}`"
target="hidden_josm_target"
>
JOSM
</el-button>

<el-button
tag="a"
size="small"
target="_blank"
:href="`https://osmlab.github.io/osm-deep-history/#/${objtypeFull(
log.objtype,
)}/${log.id}`"
title="OSM Deep History"
>
Deep H
</el-button>
<el-button
tag="a" size="small" target="_blank" :href="`https://osmlab.github.io/osm-deep-history/#/${objtypeFull(
object.objtype,
)}/${object.id}`" title="OSM Deep History"
>
Deep H
</el-button>

<el-button
tag="a"
size="small"
target="_blank"
:href="`https://pewu.github.io/osm-history/#/${objtypeFull(
log.objtype,
)}/${log.id}`"
title="OSM History Viewer"
>
OSM H
</el-button>
</el-button-group>
<el-button
tag="a"
size="small"
target="_blank"
:href="`https://pewu.github.io/osm-history/#/${objtypeFull(
object.objtype,
)}/${object.id}`"
title="OSM History Viewer"
>
OSM H
</el-button>
</el-button-group>
</template>
</div>
</template>
<el-row :gutter="20">
Expand All @@ -150,7 +141,7 @@ function objtypeFull(objtype: ObjType) {
'username',
'deleted',
'geom',
...(log.objtype !== 'r' ? ['members'] : []),
'members',
]"
:clear="['members', 'geom']"
/>
Expand Down
4 changes: 2 additions & 2 deletions libs/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ export interface Member {
}

export interface Subject extends Record<string, any> {
objtype: ObjType
id: number
version: number
deleted: boolean
changeset_id: number
Expand Down Expand Up @@ -60,8 +62,6 @@ export type LogActionOptions = Record<string, string | string[] | object>
export type Action = [string, LogAction | null, LogActionOptions | null]
export type Actions = Record<Key, Action[]>
export interface Log {
objtype: ObjType
id: number
base?: Subject
change: Subject
matches: Match[]
Expand Down

0 comments on commit 90803de

Please sign in to comment.