Skip to content

feat: Add binder import functionality with JSON file support - #37

Open
michel-montejuado with Copilot wants to merge 5 commits into
mainfrom
copilot/fix-36
Open

feat: Add binder import functionality with JSON file support#37
michel-montejuado with Copilot wants to merge 5 commits into
mainfrom
copilot/fix-36

Conversation

Copilot AI commented Jul 2, 2025

Copy link
Copy Markdown

This PR implements the requested binder import functionality allowing users to import classeurs (binders) from external JSON files.

🎯 Features Implemented

📂 Import Button

  • Added green import button with upload icon next to the existing "New" button in the Binders section
  • Triggers file selection dialog for JSON files only

🔍 File Format Validation

  • Comprehensive validation of JSON structure before import
  • Validates required fields: binder metadata, translations, optional categories and pictograms
  • Specific error messages for different validation failures

🛠️ Error Handling

  • User-friendly error dialogs with clear explanations
  • Handles invalid JSON, missing fields, incorrect data types
  • Non-blocking error display with dismissible modals

📚 Import Modes

  • Merge Mode (default): Adds imported binder to existing collection
  • Replace Mode: Completely replaces all existing binders (with warning)
  • Modal dialog for mode selection with clear descriptions

🧪 Testing

  • Manual testing: Successfully imported test binder and validated error handling
  • Unit tests: 11 comprehensive tests covering all validation scenarios
  • Build verification: All builds pass without issues

📋 JSON Import Format

The import format supports:

{
  "binder": {
    "uuid": "unique-id",
    "author": "Author Name"
  },
  "translations": [
    {
      "objectUuid": "unique-id",
      "language": "fr-FR",
      "key": "title",
      "value": "Titre du Classeur"
    }
  ],
  "categories": [...],
  "pictograms": [...]
}

🌍 Internationalization

Added French and English translations for all new UI elements:

  • Import button labels
  • Error messages
  • Mode selection dialog
  • Success/failure notifications

📖 Documentation

Created comprehensive documentation (docs/import-format.md) explaining:

  • File format specification
  • Required vs optional fields
  • Import modes explanation
  • Example files and error handling

🔧 Technical Implementation

  • Database: Transaction-based import using Dexie for data integrity
  • Validation: Robust validation with specific error messages
  • UI: Modal dialogs following existing design system
  • File Handling: FileReader API for secure client-side processing
![Import Button UI](https://github.com/user-attachments/assets/c62047cd-f7d0-4b8c-a6de-79e13b93ca11)

The import button (green with upload icon) is now available next to the "New" button in the Settings → Binders section.

This implementation provides a complete, user-friendly solution for importing binders while maintaining data integrity and providing excellent error handling.

Fixes #36.


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot wasn't able to review any files in this pull request.

@michel-montejuado
michel-montejuado marked this pull request as draft July 2, 2025 09:37
Copilot AI and others added 2 commits July 2, 2025 09:43
Co-authored-by: michel-montejuado <28892222+michel-montejuado@users.noreply.github.com>
Co-authored-by: michel-montejuado <28892222+michel-montejuado@users.noreply.github.com>
Copilot AI changed the title [WIP] Import de classeur feat: Add binder import functionality with JSON file support Jul 2, 2025
Copilot AI requested a review from michel-montejuado July 2, 2025 09:48
@Mistifiou
Mistifiou marked this pull request as ready for review July 13, 2025 10:06
Comment thread docs/import-format.md Outdated

## Overview

The binder import functionality allows you to import classeurs (binders) from external JSON files into Simple Picto. This feature supports importing binder metadata, translations, categories, and pictograms.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Il y a un soucis entre les langages sur ce fichier. Le fichier étant en anglais, il n'est pas nécessaire de parler de "classeurs".

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't forget to use english only in the code

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated the documentation to use English only. Removed French terminology like "classeurs" and standardized all content in English. Commit 3d7967c.

Comment thread docs/import-format.md Outdated

## File Format

The import file must be a valid JSON file with the following structure:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Plutôt qu'une structure, le json devrait être un json de description suivant les spécifications de open-api.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok pour OpenAPI format

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replaced the manual JSON structure documentation with a complete OpenAPI 3.0 schema specification. The documentation now follows OpenAPI standards with proper schema definitions, validation rules, and examples. Commit 3d7967c.

Comment thread docs/import-format.md Outdated
}
```

## Required Fields

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cette partie n'est plus nécessaire si le schéma précédent est un schéma open-api.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed the redundant "Required Fields" and "Optional Fields" sections since they are now fully covered by the OpenAPI schema specification. The schema provides comprehensive field definitions with validation rules. Commit 3d7967c.

@Mistifiou Mistifiou left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Il faut reprendre la méthode en prenant en compte les spécifications de open-api.

@michel-montejuado michel-montejuado left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need to apply proposed changes

…erminology

Co-authored-by: michel-montejuado <28892222+michel-montejuado@users.noreply.github.com>

Copilot AI commented Jul 13, 2025

Copy link
Copy Markdown
Author

Il faut reprendre la méthode en prenant en compte les spécifications de open-api.

Completely reworked the documentation using OpenAPI 3.0 specifications. The import format is now defined with proper schema validation, type definitions, constraints, and examples following OpenAPI standards. Commit 3d7967c.

Co-authored-by: michel-montejuado <28892222+michel-montejuado@users.noreply.github.com>

Copilot AI commented Jul 13, 2025

Copy link
Copy Markdown
Author

You need to apply proposed changes

Applied all proposed changes: converted documentation to OpenAPI 3.0 schema format and removed all French terminology from examples. Documentation now uses English only throughout. Commit 6e5a9b9.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Import de classeur

4 participants