Skip to content

Commit

Permalink
Allow legacy logs to be displayed the same as before. #261.
Browse files Browse the repository at this point in the history
  • Loading branch information
mateuswetah committed Sep 27, 2019
1 parent befa7e9 commit 18f7120
Showing 1 changed file with 245 additions and 1 deletion.
246 changes: 245 additions & 1 deletion src/admin/components/other/activity/activity-details-modal.vue
Expand Up @@ -16,7 +16,235 @@
<p><strong>{{ $i18n.get('label_activity_creation_date') }}:</strong> {{ activityCreationDate }}</p>
<p><strong>{{ $i18n.get('label_activity_author') }}:</strong> {{ activity.user_name }}</p>
</div>
<div>

<!-- LEGACY LOG API RETURN -->
<div v-if="activity.legacy != undefined && activity.legacy == true">
<template v-for="(diff, attributeName, index) in activity.log_diffs">
<div
:key="index"
class="columns">
<!-- OLD -->
<div class="column is-6">

<!-- Thumbnail -->
<div
class="content"
v-if="attributeName == 'thumbnail'">
<p class="is-capitalized has-text-blue5">
{{ attributeName }}
<small class="has-text-gray4"> {{ `(${$i18n.get('info_logs_before')})` }}</small>
</p>
<div>
<picture>
<img
width="150px"
:src="diff.old ? diff.old : placeholderSquareImage"
:alt="attributeName">
</picture>
</div>
</div>

<div
v-if="attributeName == 'attachments'"
class="content">
<p class="is-capitalized has-text-blue5">
{{ attributeName }}
<small class="has-text-gray4"> {{ `(${$i18n.get('info_logs_before')})` }}</small>
</p>
<div
class="tainacan-attachments-in-modal"
v-if="diff.old.length">
<template v-for="(attachment, anotherIndex) in diff.old">
<file-item
:key="anotherIndex"
:modal-on-click="false"
:show-name="true"
:file="{
title: { rendered: attachment.title },
guid: { rendered: attachment.url },
mime_type: attachment.mime_type,
media_type: attachment.mime_type.includes('image') ? 'image' : 'other'
}"/>
</template>
</div>
<div v-else>
<p>{{ infoEmpty }}</p>
</div>
</div>

<div
class="content"
v-if="!['thumbnail', 'attachments'].includes(attributeName)">
<p class="is-capitalized has-text-blue5">
{{ attributeName.replace(/_/g, ' ') }}
<small class="has-text-gray4"> {{ `(${$i18n.get('info_logs_before')})` }}</small>
</p>

<!-- Is array with length 1 -->
<p
class="tainacan-p-break"
v-if="(diff.old instanceof Array) &&
(diff.old.length == 1) &&
!(diff.old[0] instanceof Object)">
{{ diff.old.toString() }}
</p>

<div
v-else-if="attributeName == 'metadata_order'"
class="content">
<p
class="tainacan-p-break"
v-for="(diffContent, diffTitle) in diff.old"
:key="diffTitle">
{{ diff.old ? `ID: ${diffContent.id} | Enabled: ${diffContent.enabled}` : infoEmpty }}
</p>
</div>

<div
v-else-if="attributeName == 'filters_order'"
class="content">
<p
class="tainacan-p-break"
v-for="(diffContent, diffTitle) in diff.old"
:key="diffTitle">
{{ diff.old ? `ID: ${diffContent.id} | Enabled: ${diffContent.enabled}` : infoEmpty }}
</p>
</div>

<div
v-else-if="attributeName == 'metadata_type_options'"
class="content">
<p class="tainacan-p-break">
{{ diff.old ?
`Taxonomy ID: ${diff.old.taxonomy_id};
Input type: ${diff.old.input_type};
Allow new terms: ${diff.old.allow_new_terms}` : infoEmpty }}
</p>
</div>

<!-- -->
<p
class="tainacan-p-break"
v-else>
{{ diff.old ? (diff.old instanceof Array && !diff.old.length) ? infoEmpty : diff.old.toString().replace(/,/g, ' ') : infoEmpty }}
</p>

</div>
</div>

<!-- NEW -->
<div class="column is-6">

<!-- Thumbnail -->
<div
class="content"
v-if="attributeName == 'thumbnail'">
<p class="is-capitalized has-text-blue5">
{{ attributeName }}
<small class="has-text-gray4"> {{ `(${$i18n.get('info_logs_after')})` }}</small>
</p>
<div>
<picture>
<img
width="150px"
:src="diff.new ? diff.new : placeholderSquareImage"
:alt="attributeName">
</picture>
</div>
</div>

<div
v-if="attributeName == 'attachments'"
class="content">
<p class="is-capitalized has-text-blue5">
{{ attributeName }}
<small class="has-text-gray4"> {{ `(${$i18n.get('info_logs_after')})` }}</small>
</p>
<div
class="tainacan-attachments-in-modal"
v-if="diff.new.length">
<template v-for="(attachment, index) in diff.new">
<file-item
:key="index"
:modal-on-click="false"
:show-name="true"
:file="{
title: { rendered: attachment.title },
guid: { rendered: attachment.url },
mime_type: attachment.mime_type,
media_type: attachment.mime_type.includes('image') ? 'image' : 'other'
}"/>
</template>
</div>
<div v-else>
<p>{{ infoEmpty }}</p>
</div>
</div>

<div
class="content"
v-if="!['thumbnail', 'attachments'].includes(attributeName)">
<p class="is-capitalized has-text-blue5">
{{ attributeName.replace(/_/g, ' ') }}
<small class="has-text-gray4"> {{ `(${$i18n.get('info_logs_after')})` }}</small>
</p>

<!-- Is array with length 1 -->
<p
class="tainacan-p-break"
v-if="(diff.new instanceof Array) &&
(diff.new.length == 1) &&
!(diff.new[0] instanceof Object)">
{{ diff.new.toString() }}
</p>


<div
v-else-if="attributeName == 'metadata_order'"
class="content">
<p
class="tainacan-p-break"
v-for="(diffContent, diffTitle) in diff.new"
:key="diffTitle">
{{ `ID: ${diffContent.id} | Enabled: ${diffContent.enabled}` }}
</p>
</div>

<div
v-else-if="attributeName == 'filters_order'"
class="content">
<p
class="tainacan-p-break"
v-for="(diffContent, diffTitle) in diff.new"
:key="diffTitle">
{{ `ID: ${diffContent.id} | Enabled: ${diffContent.enabled}` }}
</p>
</div>

<div
v-else-if="attributeName == 'metadata_type_options'"
class="content">
<p class="tainacan-p-break">
{{ `Taxonomy ID: ${diff.new.taxonomy_id};
Input type: ${diff.new.input_type};
Allow new terms: ${diff.new.allow_new_terms}` }}
</p>
</div>

<!-- -->
<p
class="tainacan-p-break"
v-else>
{{ diff.new ? (diff.new instanceof Array && !diff.new.length) ? infoEmpty : diff.new.toString().replace(/,/g, ' ') : infoEmpty }}
</p>

</div>
</div>
</div>
</template>
</div>
<!-- NEW LOG API RETURN -->
<div v-else>
<div class="columns">
<!-- OLD -->
<div class="column is-6">
Expand Down Expand Up @@ -445,6 +673,22 @@
}
}
.tainacan-attachments-in-modal {
display: flex;
flex-wrap: wrap;
flex-direction: row;
align-content: baseline;
resize: vertical;
overflow-y: auto;
overflow-x: hidden;
height: 200px;
border: 1px solid $gray3;
&>div {
margin: 0.5rem;
}
}
.tainacan-p-overflow {
text-overflow: ellipsis;
white-space: nowrap;
Expand Down

0 comments on commit 18f7120

Please sign in to comment.