Skip to content

Commit

Permalink
Assets report filename is now personalized (#436)
Browse files Browse the repository at this point in the history
* Assets report filename is now personalized

* npm update
  • Loading branch information
turulomio authored Jul 26, 2024
1 parent 781e661 commit 18ae346
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 21 deletions.
5 changes: 5 additions & 0 deletions cypress/e2e/AssetsReport.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ describe('e2e Assets Report', () => {

login_test_User(cy)
//Open lateral menu
cy.getDataTest('LateralSettings').click()
cy.getDataTest('Settings_FirstName').clear().type("Paco")
cy.getDataTest('Settings_LastName').clear().type("Pérez Pérez")
cy.getDataTest('Settings_ButtonSave').click()

cy.getDataTest('LateralAssetsReport').click()
cy.getDataTest('AssetsReport_ButtonGenerate').click()
cy.wait(30000)
Expand Down
28 changes: 14 additions & 14 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
Expand Up @@ -47,7 +47,7 @@
"eslint-plugin-vue": "^9.27.0",
"globals": "^15.8.0",
"npm-check-updates": "^16.14.20",
"vite": "^5.3.4",
"vite": "^5.3.5",
"vite-plugin-eslint": "^1.8.1",
"vite-plugin-istanbul": "^6.0.2",
"vite-plugin-vue-devtools": "^7.3.7",
Expand Down
10 changes: 7 additions & 3 deletions src/components/AssetsReport.vue
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
},
data(){
return {
reportdate:new Date(),
loading:true,
creating:false,
key:0,
Expand Down Expand Up @@ -147,7 +148,7 @@
{ image: await pdfmake_convertImageToDataURL(imgMoneymoney), width: 200, alignment: 'center', margin: [0, 125, 0, 0] },
{ text: 'Assets report', style: 'header1', alignment:'center' },
{ text: f(this.$t(`Generated by MoneyMoney-[0]`), [this.useStore().version,]), style: 'body', alignment:'center' },
{ text: new Intl.DateTimeFormat('es-ES', { year: 'numeric', month: 'long', day: 'numeric', hour: 'numeric', minute: 'numeric', second: 'numeric', hour12: false }).format(new Date()), style: 'body', alignment:'center' , margin: [0, 300, 0, 200],pageBreak:'after' },
{ text: new Intl.DateTimeFormat('es-ES', { year: 'numeric', month: 'long', day: 'numeric', hour: 'numeric', minute: 'numeric', second: 'numeric', hour12: false }).format(this.reportdate), style: 'body', alignment:'center' , margin: [0, 300, 0, 200],pageBreak:'after' },
{ toc: { title: { text: 'Table of Contents', style: 'header1', numberStyle: 'normal'}}, pageBreak:"after"},
Expand Down Expand Up @@ -215,7 +216,11 @@
}
console.log("PDFMAKE", docDefinition)
await pdfMake.createPdf(docDefinition,{tagged:true}).download('report.pdf');
var datestring=this.reportdate.toISOString().split(".")[0].replaceAll("-","").replace("T"," ").replaceAll(":","")
var filename=`${datestring} AssetsReport ${ this.useStore().getProfileUppercaseChars}.pdf`
await pdfMake.createPdf(docDefinition,{tagged:true}).download(filename);
this.creating=false
},
Expand Down Expand Up @@ -638,7 +643,6 @@
},
},
created(){
console.log()
this.get_report_data()
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/components/Settings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
<v-window-item key="profile" >
<v-card class="mx-auto pa-6 mt-3">
<v-card-title>{{ $t('Profile settings') }}</v-card-title>
<v-text-field v-model="new_profile.first_name" :label="$t('Set your name')" :placeholder="$t('Set your name')" :rules="RulesString(200,true)" counter="200"/>
<v-text-field v-model="new_profile.last_name" :label="$t('Set your last name')" :placeholder="$t('Set your last name')" :rules="RulesString(200,true)" counter="200"/>
<v-text-field data-test="Settings_FirstName" v-model="new_profile.first_name" :label="$t('Set your name')" :placeholder="$t('Set your name')" :rules="RulesString(200,true)" counter="200"/>
<v-text-field data-test="Settings_LastName" v-model="new_profile.last_name" :label="$t('Set your last name')" :placeholder="$t('Set your last name')" :rules="RulesString(200,true)" counter="200"/>
<v-text-field v-model="new_profile.email" :label="$t('Set your email')" :placeholder="$t('Set your email')" :rules="RulesEmail(true)" counter="200"/>
<v-text-field type="password" v-model="new_profile.newp" :label="$t(`Set your new password. Leave empty if you don't want to change it`)" :placeholder="$t('Set your password')" :rules="RulesPassword(40,false)" counter="40"/>
<v-text-field type="password" v-model="dupnewp" :label="$t(`Set your new password. Leave empty if you don't want to change it`)" :placeholder="$t('Set your password')" :rules="RulesPassword(40,false)" counter="40"/>
Expand Down Expand Up @@ -54,7 +54,7 @@
</v-window-item>
</v-window>
<div class="mx-auto pa-5" align="center">
<v-btn color="error" @click="save_settings()">{{ $t("Save settings")}}</v-btn>
<v-btn data-test="Settings_ButtonSave" color="error" @click="save_settings()">{{ $t("Save settings")}}</v-btn>
</div>
</v-form>
</v-card>
Expand Down
13 changes: 13 additions & 0 deletions src/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,19 @@ export const useStore = defineStore('global', {
getters:{
getOperationstypesForNewConcepts(state) {
return getArrayFromMap(state.operationstypes).filter( o => [1,2].includes(o.id))
},
getProfileUppercaseChars(state) {
// Helper function to get uppercase characters from a string
function getUppercaseChars(str) {
return str.replace(/[^A-Z]/g, '');
}

// Get the uppercase characters of each string
const upperChars1 = getUppercaseChars(state.profile.first_name);
const upperChars2 = getUppercaseChars(state.profile.last_name);

// Join the uppercase characters together
return upperChars1 + upperChars2
}
},
actions: {
Expand Down

0 comments on commit 18ae346

Please sign in to comment.