Skip to content

Commit

Permalink
Merge pull request #96 from oatear/main
Browse files Browse the repository at this point in the history
Update branch
  • Loading branch information
hristoiankov committed Jan 15, 2024
2 parents 06baf91 + 214a729 commit 2c5bad5
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 10 deletions.
2 changes: 1 addition & 1 deletion cider-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"author": {
"name": "Hristo Iankov"
},
"version": "0.4.6",
"version": "0.4.8",
"repository": "https://github.com/oatear/cider",
"main": "electron-app/dist/main.js",
"scripts": {
Expand Down
8 changes: 5 additions & 3 deletions cider-app/src/app/data-services/electron/electron.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,11 @@ export class ElectronService {
this.projectUnsaved = new BehaviorSubject<boolean>(false);
this.appClosed = new Subject<null>();

this.getIpcRenderer().on('app-closed', () => {
this.appClosed.next(null);
});
if (this.isElectron()) {
this.getIpcRenderer().on('app-closed', () => {
this.appClosed.next(null);
});
}
}

public getProjectHomeUrl() {
Expand Down
2 changes: 1 addition & 1 deletion cider-app/src/app/data-services/services/cards.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export class CardsService extends DecksChildService<Card, number> {
const attributes = await this.attributesService.getAll(equalityCriterias);
return this.fields.concat(attributes.map(attribute => {
return {
field: attribute.name.trim().replace(/ /g, '-').toLowerCase(),
field: ('' + attribute.name).trim().replace(/ /g, '-').toLowerCase(),
header: attribute.name,
type: attribute.type,
description: attribute.description,
Expand Down
2 changes: 2 additions & 0 deletions cider-app/src/app/export-cards/export-cards.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,8 @@
<div class="p-field">
<p-message severity="info"
text="Make sure this DPI is the same target DPI for the card templates and always set 'flip on long edge' when printing."></p-message>
<p-message severity="error" class="p-ml-1" *ngIf="someCardsMissingTemplates"
text="Some cards do not have both their back and front template selected and will not appear in the export."></p-message>
</div>
</ng-container>
<ng-container *ngIf="exportType === 'singular-export'">
Expand Down
8 changes: 6 additions & 2 deletions cider-app/src/app/export-cards/export-cards.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ export class ExportCardsComponent implements OnInit {
public maxTtsPixels: number = 4096;
public scale: number = 0.1;
public exportSelectionDialogVisible: boolean = false;
public someCardsMissingTemplates: boolean = false;
renderCache: boolean = false;
zoomOptions: any[] = [
{ label: 's', value: 0.05 },
Expand All @@ -77,8 +78,11 @@ export class ExportCardsComponent implements OnInit {
constructor(cardsService: CardsService,
public templatesService: CardTemplatesService) {
cardsService.getAll().then(cards => {
this.originalCards = cards;
this.cards = cards;
// check cards for front/back templates being defined
const cardsWithTemplatesDefined = cards.filter(card => card.backCardTemplateId && card.frontCardTemplateId);
this.someCardsMissingTemplates = cards.length != cardsWithTemplatesDefined.length;
this.originalCards = cardsWithTemplatesDefined;
this.cards = cardsWithTemplatesDefined;
this.updateExpandedCards();
this.updateSlices();
});
Expand Down
2 changes: 1 addition & 1 deletion cider-app/src/app/shared/utils/string-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export default class StringUtils {
if (!input) {
return input;
}
return input.trim().replace(/ /g, '-').toLowerCase();
return ('' + input).trim().replace(/ /g, '-').toLowerCase();
}

/**
Expand Down
4 changes: 2 additions & 2 deletions cider-app/src/app/shared/utils/xlsx-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export default class XlsxUtils {
static entityExportToFile<Entity>(columns: EntityField<Entity>[],
lookups: Map<EntityService<any, string | number>, Map<string | number, string>>, records: Entity[]) {
const csv = XlsxUtils.entityExport(columns, lookups, records);
const blob = new Blob([csv], {type: 'text/csv'});
const blob = new Blob([csv], {type: 'text/csv;charset=utf-8'});
FileUtils.saveAs(blob, 'data.csv');
}

Expand All @@ -63,7 +63,7 @@ export default class XlsxUtils {
file: File): Promise<Entity[]> {
const headers = columns.filter(column => !column.hidden);
return file.arrayBuffer().then(buffer => {
const workbook: XLSX.WorkBook = XLSX.read(buffer, {type: "buffer"});
const workbook: XLSX.WorkBook = XLSX.read(buffer, {type: "buffer", codepage: 65001});
const worksheet: XLSX.WorkSheet = workbook.Sheets[workbook.SheetNames[0]];
const parsedObjects = XLSX.utils.sheet_to_json(worksheet);
const convertedObjects = parsedObjects.map(object => {
Expand Down

0 comments on commit 2c5bad5

Please sign in to comment.