Skip to content

Commit

Permalink
Merge branch 'next' into observation/FOUR-13914-b
Browse files Browse the repository at this point in the history
  • Loading branch information
mcraeteisha authored Feb 9, 2024
2 parents bb19181 + 1d74021 commit 3998dc3
Show file tree
Hide file tree
Showing 6 changed files with 130 additions and 3 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@processmaker/screen-builder",
"version": "2.83.6",
"version": "2.83.7",
"scripts": {
"dev": "VITE_COVERAGE=true vite",
"build": "vite build",
Expand Down
2 changes: 2 additions & 0 deletions src/components/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import ScreenRenderer from "./screen-renderer.vue";
import AddLoopRow from "./renderer/add-loop-row.vue";
import FormRecordList from "./renderer/form-record-list.vue";
import FormImage from "./renderer/form-image.vue";
import FormAvatar from "./renderer/form-avatar.vue";
import "@processmaker/vue-form-elements/dist/vue-form-elements.css";
import FormButton from "./renderer/form-button.vue";
import FileUpload from "./renderer/file-upload.vue";
Expand Down Expand Up @@ -136,6 +137,7 @@ export default {
// Register the builder and renderer
Vue.component("AddLoopRow", AddLoopRow);
Vue.component("FormImage", FormImage);
Vue.component("FormAvatar", FormAvatar);
Vue.component("FormLoop", FormLoop);
Vue.component("FormMultiColumn", FormMultiColumn);
Vue.component("FormNestedScreen", FormNestedScreen);
Expand Down
79 changes: 79 additions & 0 deletions src/components/renderer/form-avatar.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
<template>
<span>
<b-button
:variant="variant()"
class="avatar-button rounded-circle overflow-hidden p-0 m-0 d-inline-flex border-0"
:style="styleAvatar()"
disabled
>
<img
v-if="user.avatar"
:src="user.avatar"
:width="width"
:height="height"
:class="image"
:alt="user.fullname"
/>
<span
v-else
class="border-0 d-inline-flex align-items-center justify-content-center text-white text-uppercase text-nowrap font-weight-normal"
:style="styleAvatar()"
>
<span v-if="getInitials()">{{ getInitials() }}</span>
<span v-else>PM</span>
</span>
</b-button>
</span>
</template>

<script>
export default {
props: {
width: {
default: 64,
},
height: {
default: 64,
},
},
data() {
return {
user: window.Processmaker.user,
};
},
mounted() {
this.getInitials();
},
methods: {
getInitials() {
return this.user.firstname && this.user.lastname
? this.user.firstname.match(/./u)[0] + this.user.lastname.match(/./u)[0]
: "";
},
variant() {
return this.user.avatar ? 'secondary' : 'info';
},
styleAvatar() {
return "width: " +
this.width +
"px; height: " +
this.height +
"px; font-size:" +
this.height / 2.5 +
"px; padding:0;";
}
}
};
</script>

<style lang="scss" scoped>
.avatar-button:disabled {
opacity: 1;
pointer-events: none;
}
.empty-image {
font-size: 2em;
}
</style>

1 change: 1 addition & 0 deletions src/components/renderer/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
export { default as AddLoopRow } from "./add-loop-row.vue";
export { default as FileDownload } from "./file-download.vue";
export { default as FileUpload } from "./file-upload.vue";
export { default as FormAvatar } from "./form-avatar.vue";
export { default as FormButton } from "./form-button.vue";
export { default as FormImage } from "./form-image.vue";
export { default as FormInputMasked } from "./form-masked-input.vue";
Expand Down
45 changes: 45 additions & 0 deletions src/form-builder-controls.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import FormText from './components/renderer/form-text';
import FormAvatar from './components/renderer/form-avatar';
import FormButton from './components/renderer/form-button';
import FormMultiColumn from './components/renderer/form-multi-column';
import FormLoop from './components/renderer/form-loop';
Expand Down Expand Up @@ -580,6 +581,50 @@ export default [
],
},
},
{
editorComponent: FormAvatar,
editorBinding: 'FormAvatar',
rendererComponent: FormAvatar,
rendererBinding: 'FormAvatar',
control: {
popoverContent: "User avatar",
order: 3.0,
group: 'Dashboards',
label: 'User Avatar',
component: 'FormAvatar',
'editor-component': 'FormAvatar',
'editor-control': 'FormAvatar',
config: {
label: 'User Avatar',
icon: 'fas fa-user-circle',
variant: 'primary',
event: 'submit',
name: null,
value: null,
renderImage: false,
},
inspector: [
{
type: 'FormInput',
field: 'height',
config: {
label: 'Height',
helper: 'Avatar height',
type: 'number',
},
},
{
type: 'FormInput',
field: 'width',
config: {
label: 'Width',
helper: 'Avatar width',
type: 'number',
},
},
],
},
},
{
editorComponent: FormButton,
editorBinding: 'FormSubmit',
Expand Down

0 comments on commit 3998dc3

Please sign in to comment.