Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[OP#48106] link previews UI implementation #428

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/Reference/WorkPackageReferenceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ public function resolveReference(string $referenceText): ?IReference {
// this is the data you will get in your custom reference widget
$reference->setRichObject(
self::RICH_OBJECT_TYPE,
$wpInfo
$wpInfo['entry']
);
return $reference;
}
Expand Down
1 change: 1 addition & 0 deletions lib/Service/OpenProjectAPIService.php
Original file line number Diff line number Diff line change
Expand Up @@ -1155,6 +1155,7 @@ public function getWorkPackageInfo(string $userId, int $wpId): array {
$result['title'] = $this->getSubline($searchResult[0]);
$result['description'] = $this->getMainText($searchResult[0]);
$result['imageUrl'] = $this->getOpenProjectUserAvatarUrl($searchResult[0]);
$result['entry'] = $searchResult[0];
return $result;
}

Expand Down
5 changes: 0 additions & 5 deletions src/components/PersonalSettings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,6 @@ export default {
},
},
watch: {
'state.notification_enabled'(newVal) {
SwikritiT marked this conversation as resolved.
Show resolved Hide resolved
this.saveOptions({
notification_enabled: newVal ? '1' : '0',
})
},
'state.search_enabled'(newVal) {
this.saveOptions({
search_enabled: newVal ? '1' : '0',
Expand Down
9 changes: 6 additions & 3 deletions src/utils/workpackageHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export const workpackageHelper = {
? href.replace(/.*\//, '')
: null
},
async getAdditionalMetaData(workPackage) {
async getAdditionalMetaData(workPackage, linkableWorkpackage = false) {
if (typeof workPackage._links.status.href !== 'string'
|| workPackage._links.status.href === ''
|| typeof workPackage._links.type.href !== 'string'
Expand All @@ -41,11 +41,14 @@ export const workpackageHelper = {
|| workPackage._links.status.title === ''
|| typeof workPackage._links.type.title !== 'string'
|| workPackage._links.type.title === ''
|| typeof workPackage.fileId !== 'number'
|| workPackage.fileId <= 0
) {
throw new Error('missing data in workpackage object')
}

if (linkableWorkpackage && typeof workPackage.fileId !== 'number' && workPackage.fileId <= 0) {
throw new Error('missing data in workpackage object')
}

const statusId = this.replaceHrefToGetId(workPackage._links.status.href)
const typeId = this.replaceHrefToGetId(workPackage._links.type.href)
const userId = this.replaceHrefToGetId(workPackage._links.assignee.href)
Expand Down
2 changes: 1 addition & 1 deletion src/views/ProjectsTab.vue
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ export default {
// and came back to a file that was selected before and so work-packages are already
// in the list. In that case don't even try to fetch all the additional meta data
if (!this.workpackageAlreadyInList(workPackage)) {
workPackage = await workpackageHelper.getAdditionalMetaData(workPackage)
workPackage = await workpackageHelper.getAdditionalMetaData(workPackage, true)
// check again, the WP might have been added by an outstanding request
// from another file or the file might have changed while fetching metadata
if (
Expand Down
28 changes: 17 additions & 11 deletions src/views/WorkPackageReferenceWidget.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,23 +31,26 @@
{{ t('integration_openproject', 'OpenProject settings') }}
</a>
</div>
<div v-else class="work-package-wrapper">
{{ richObject.title }}
</div>
<WorkPackage :id="'workpackage-'+ richObject.id"
class="work-package-reference__link-preview"
:workpackage="workpackage" />
</div>
</template>

<script>
import CloseIcon from 'vue-material-design-icons/Close.vue'
import OpenInNewIcon from 'vue-material-design-icons/OpenInNew.vue'
import { generateUrl } from '@nextcloud/router'
import WorkPackage from '../components/tab/WorkPackage.vue'
import { workpackageHelper } from '../utils/workpackageHelper.js'

export default {
name: 'WorkPackageReferenceWidget',

components: {
OpenInNewIcon,
CloseIcon,
WorkPackage,
},

props: {
Expand All @@ -68,6 +71,7 @@ export default {
data() {
return {
settingsUrl: generateUrl('/settings/user/openproject'),
workpackage: null,
}
},

Expand All @@ -77,7 +81,14 @@ export default {
},
},

mounted() {
this.processWorkpackages()
},

methods: {
async processWorkpackages() {
this.workpackage = await workpackageHelper.getAdditionalMetaData(this.richObject)
},
},
}
</script>
Expand All @@ -86,7 +97,9 @@ export default {
.work-package-reference {
width: 100%;
white-space: normal;
padding: 12px;
&__link-preview {
border-bottom: none;
}

a {
padding: 0 !important;
Expand All @@ -104,13 +117,6 @@ export default {
}
}

.work-package-wrapper {
width: 100%;
display: flex;
align-items: start;

}

.settings-link {
display: flex;
align-items: center;
Expand Down