Skip to content

Commit

Permalink
Merge branch 'pu/sd/personasInModals' into '2024.11'
Browse files Browse the repository at this point in the history
Personas in modals.

See merge request tine20/tine20!4576
  • Loading branch information
Sohan Deshar committed Jan 16, 2024
2 parents 83e51e3 + a36d845 commit caac13c
Show file tree
Hide file tree
Showing 12 changed files with 223 additions and 99 deletions.
47 changes: 22 additions & 25 deletions tine20/Filemanager/js/DuplicateFileUploadDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
* @copyright Copyright (c) 2021 Metaways Infosystems GmbH (http://www.metaways.de)
*/

import {PersonaContainer, Personas} from "../../Tinebase/js/ux/vue/PersonaContainer";

Ext.ns('Tine.Filemanager');

Tine.Filemanager.DuplicateFileUploadDialog = Ext.extend(Ext.FormPanel, {
Expand Down Expand Up @@ -59,7 +61,7 @@ Tine.Filemanager.DuplicateFileUploadDialog = Ext.extend(Ext.FormPanel, {
];

this.initButtons();

this.itemsName = this.id + '-radioItems';

this.items = {
Expand All @@ -68,30 +70,25 @@ Tine.Filemanager.DuplicateFileUploadDialog = Ext.extend(Ext.FormPanel, {
layoutConfig: {
align:'stretch'
},
items : [
{
border: false,
html: '<div class="x-window-dlg"><div class="ext-mb-icon ext-mb-question"></div></div>',
flex: 0,
width: 45
items : [new PersonaContainer({
flex: 0,
persona: Personas.WARNING
}), {
border: false,
layout: 'vbox',
flex: 1,
layoutConfig: {
align:'stretch'
},
{
border: false,
layout: 'vbox',
flex: 1,
layoutConfig: {
align:'stretch'
},
items: [
{
xtype: 'label',
border: false,
cls: 'ext-mb-text',
html: this.questionText
}
]
}
]
items: [
{
xtype: 'label',
border: false,
cls: 'ext-mb-text',
html: this.questionText
}
]
}]
};

Tine.Filemanager.DuplicateFileUploadDialog.superclass.initComponent.call(this);
Expand Down Expand Up @@ -185,7 +182,7 @@ Tine.Filemanager.DuplicateFileUploadDialog.openWindow = function (config) {
closable: false,
title: this.app.i18n._('Overwrite Existing File?'),
width: config.width || 400,
height: config.height || 150,
height: Math.max(config.height || 150, 200),
name: prototype.windowNamePrefix + Ext.id(),
contentPanelConstructor: constructor,
contentPanelConstructorConfig: config,
Expand Down
84 changes: 54 additions & 30 deletions tine20/Tinebase/js/ExceptionDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

/*global Ext, Tine, window*/

import { PersonaContainer, Personas } from "./ux/vue/PersonaContainer";

Ext.ns('Tine', 'Tine.Tinebase');

/**
Expand Down Expand Up @@ -131,7 +133,6 @@ Tine.Tinebase.ExceptionDialog = Ext.extend(Ext.Window, {
*/
getReportForm: function () {
this.initButtons();

this.reportForm = new Ext.FormPanel({
id: 'tb-exceptiondialog-frompanel',
bodyStyle: 'padding:5px;',
Expand All @@ -141,36 +142,59 @@ Tine.Tinebase.ExceptionDialog = Ext.extend(Ext.Window, {
buttons: this.reportButtons,
items: [{
xtype: 'panel',
layout: 'hbox',
border: false,
html: '<div class="tb-exceptiondialog-text">' +
'<p>' + i18n._('An error occurred, the program ended abnormal.') + '</p>' +
'<p>' + i18n._('The last action you made was potentially not performed correctly.') + '</p>' +
'<p>' + i18n._('Please help improving this software and notify the vendor. Include a brief description of what you where doing when the error occurred.') + '</p>' +
'</div>'
}, {
id: 'tb-exceptiondialog-description',
height: 60,
xtype: 'textarea',
fieldLabel: i18n._('Description'),
name: 'description',
anchor: '95%',
readOnly: false
}, {
xtype: 'fieldset',
id: 'tb-exceptiondialog-send-contact',
anchor: '95%',
title: i18n._('Send Contact Information'),
autoHeight: true,
checkboxToggle: true,
items: [{
id: 'tb-exceptiondialog-contact',
xtype: 'textfield',
hideLabel: true,
anchor: '100%',
name: 'contact',
value: (this.currentAccount) ? this.currentAccount.accountFullName + ' ' + this.currentAccount.accountEmailAddress : 'unknown'
}]
}, {
layoutConfig: {
align: 'stretchmax'
},
items: [
new PersonaContainer({
persona: Personas.ERROR_SEVERE,
flex: 0,
width: 100,
height: 200
}),
{
border: false,
flex: 1,
layout: 'form',
items: [
{
xtype: 'panel',
border: false,
html: '<div class="tb-exceptiondialog-text">' +
'<p>' + i18n._('An error occurred, the program ended abnormal.') + '</p>' +
'<p>' + i18n._('The last action you made was potentially not performed correctly.') + '</p>' +
'<p>' + i18n._('Please help improving this software and notify the vendor. Include a brief description of what you where doing when the error occurred.') + '</p>' +
'</div>'
}, {
id: 'tb-exceptiondialog-description',
height: 60,
xtype: 'textarea',
fieldLabel: i18n._('Description'),
name: 'description',
anchor: '95%',
readOnly: false
}, {
xtype: 'fieldset',
id: 'tb-exceptiondialog-send-contact',
anchor: '95%',
title: i18n._('Send Contact Information'),
autoHeight: true,
checkboxToggle: true,
items: [{
id: 'tb-exceptiondialog-contact',
xtype: 'textfield',
hideLabel: true,
anchor: '100%',
name: 'contact',
value: (this.currentAccount) ? this.currentAccount.accountFullName + ' ' + this.currentAccount.accountEmailAddress : 'unknown'
}]
},
]
}
]
},{
xtype: 'panel',
width: '95%',
layout: 'form',
Expand Down
20 changes: 13 additions & 7 deletions tine20/Tinebase/js/PasswordChangeDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@
* @copyright Copyright (c) 2010-2017 Metaways Infosystems GmbH (http://www.metaways.de)
*
*/

Ext.ns('Tine', 'Tine.Tinebase');

// import {PersonaContainer, Personas} from "./ux/vue/PersonaContainer";

Ext.ns('Tine', 'Tine.Tinebase');

/**
* @namespace Tine.Tinebase
Expand All @@ -20,10 +22,10 @@ Tine.Tinebase.PasswordChangeDialog = Ext.extend(Ext.Window, {
closeAction: 'close',
modal: true,
width: 350,
height: 350,
height: 230,
minWidth: 350,
minHeight: 230,
layout: 'fit',
layout: 'column',
plain: true,
title: null,
// password or pin
Expand All @@ -38,8 +40,12 @@ Tine.Tinebase.PasswordChangeDialog = Ext.extend(Ext.Window, {
this.passwordLabel,
this.currentAccount.accountDisplayName
);

this.items = new Ext.FormPanel({
this.items = []
// const persona = new PersonaContainer({persona: Personas.QUESTION_CONFIRM, columnWidth: .2})
// this.items.push(persona)
this.items.push(new Ext.FormPanel({
// columnWidth: .8,
autoHeight: true,
bodyStyle: 'padding:5px;',
buttonAlign: 'right',
labelAlign: 'top',
Expand Down Expand Up @@ -142,7 +148,7 @@ Tine.Tinebase.PasswordChangeDialog = Ext.extend(Ext.Window, {
},
scope: this
}]
});
}));

Tine.Tinebase.PasswordChangeDialog.superclass.initComponent.call(this);
}
Expand Down
55 changes: 55 additions & 0 deletions tine20/Tinebase/js/ux/vue/PersonaContainer/PersonaContainer.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<!--
/*
* Tine 2.0
*
* @license http://www.gnu.org/licenses/agpl.html AGPL Version 3
* @author Sohan Deshar <s.deshar@metaways.de>
* @copyright Copyright (c) 2022-2023 Metaways Infosystems GmbH (http://www.metaways.de)
*/
-->
<template>
<div v-html="rawSvg" class="dark-reverse vue-msg-box-svg-container" :style="`--skin-color: ${skinColor}`"></div>
</template>

<script setup>
import { onBeforeMount, ref } from 'vue'

import getIconPath from './helpers'

const props = defineProps({
iconName: {
type: String,
required: true
},
skinColor: {
type: String,
required: false
}
})

const rawSvg = ref(null)
const skinColor = ref(null)

const skinShades = ['#ffffff', '#fad9b4', '#fcbf89', '#ec8f2e', '#d97103', '#b75b01', '#924500']
const init = async function () {
const { default: img } = await import(/* webpackChunkName: "Tinebase/js/[request]" */`images/dialog-personas/${getIconPath(props.iconName)}.svg`)
skinColor.value = props.skinColor ? props.skinColor : skinShades[Math.floor(Math.random() * skinShades.length)]
rawSvg.value = window.atob(img.split(',')[1])
}

onBeforeMount(async () => {
await init()
})
</script>

<style lang="scss">
.vue-msg-box-svg-container {
svg{
height: 100%;
width: auto;
}
.skin {
fill: var(--skin-color) !important;
}
}
</style>
45 changes: 45 additions & 0 deletions tine20/Tinebase/js/ux/vue/PersonaContainer/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
Ext.ns("Tine.ux.vue")
Ext.ns("Tine.personas")

export const Personas = Object.freeze({
INFO : 'info_default',
INFO_INSTRUCTION: 'info_instruction',
INFO_FAILURE: 'info_failure',
INFO_SUCCESS: 'info_success',
INFO_WAIT: 'info_wait',

WARNING : 'warning',

QUESTION : 'question_default',
QUESTION_INPUT: 'question_input',
QUESTION_OPTION: 'question_option',
QUESTION_CONFIRM: 'question_confirm',
QUESTION_WARN: 'question_warn',

ERROR : 'error_default',
ERROR_MILD: 'error_mild',
ERROR_SEVERE: 'error_severe',
})

export const PersonaContainer = Ext.extend(Ext.BoxComponent, {
width: 100,
height: 200,
persona: Personas.INFO,

onRender: async function (ct, position){
Ext.BoxComponent.superclass.onRender.call(this, ct, position)
window.vue = window.vue || await import(/* webpackChunkName: "Tinebase/js/Vue-Runtime" */"tine-vue")
const { default: PersonaContainer } = await import("./PersonaContainer.vue")
this.app = vue.createApp(
PersonaContainer,
{
iconName: this.initialConfig.persona,
skinColor: this.initialConfig.skinColor
})
this.app.mount(`#${this.id}`)
},
})

Tine.personas = Personas
Tine.ux.vue.PersonaContainer = PersonaContainer
Ext.reg('vpersona', Tine.ux.vue.PersonaContainer)
10 changes: 7 additions & 3 deletions tine20/Tinebase/js/widgets/dialog/FileListDialog.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import {PersonaContainer, Personas} from "../../ux/vue/PersonaContainer";

Ext.ns('Tine.widgets.dialog');

Expand Down Expand Up @@ -55,7 +56,7 @@ Ext.extend(Tine.widgets.dialog.FileListDialog, Ext.FormPanel, {
initComponent: function() {
// init buttons and tbar
this.initButtons();

this.itemsName = this.id + '-fileListc';

// get items for this dialog
Expand All @@ -65,7 +66,10 @@ Ext.extend(Tine.widgets.dialog.FileListDialog, Ext.FormPanel, {
layoutConfig: {
align:'stretch'
},
items: [{
items: [new PersonaContainer({
persona: Personas.WARNING,
flex: 0,
}),{
border: false,
layout: 'fit',
flex: 1,
Expand Down Expand Up @@ -131,7 +135,7 @@ Ext.extend(Tine.widgets.dialog.FileListDialog, Ext.FormPanel, {
Tine.widgets.dialog.FileListDialog.openWindow = function (config) {
var window = Tine.WindowFactory.getWindow({
width: config.width || 400,
height: config.height || 150,
height: Math.max(config.height || 150, 200),
closable: false,
name: Tine.widgets.dialog.FileListDialog.windowNamePrefix + Ext.id(),
contentPanelConstructor: 'Tine.widgets.dialog.FileListDialog',
Expand Down
Loading

0 comments on commit caac13c

Please sign in to comment.