Background
...
'Update Toc' button is updated in the 'sunbirdcommonheader' plugin, on click of the button, we are dispatching an event 'org.ekstep.uploadtocuploadfile:show'
The plugin to upload the CSV file(should be configurable) will listen to the event org.ekstep.uploadtocuploadfile:show
The configurations for the plugin will be the title, description, file formats .
To provide the upload file with drag and drop feature, the library fineuploader
used in the `org.ekstep.uploadcontent` plugin will be utilized, the suggested name of the plugin is `org.ekstep.uploadtocuploadfile-1.0`
The CSV file should have the updated attributes like Name, Description, topics, keywords, DIAL code
...
the request of the api will be request { data : [file] }
and notify the user if there are any errors from the error response and update the Text book unit attributes on success of api response
On success of the response update the attributes , read the getHeirarchy?mode=edit to get the updated attribute values of the textbook unit and assign it to data.
Now dispatch the event `org.ekstep.collectioneditor:content:update`, with data from the getHierarchy result, the org.ekstep.contentMeta plugin will listen to the event and update the attributes of TOC
Pros:
Plugin can be reused in multiple places like upload the CSVfor any file upload.
Cons
Basic validations like empty record check is known after the api call.
Solution 2:
Provide the upload feature with out the plugin, provide the drag and drop / upload file in the 'sunbirdcommonheader' plugin.
Validate if the CSV file is uploaded else throw an error saying, uploaded_file_name has a invalid extension, Please enter a .CSV file.
the request of the api will be request After upload of CSV using the 'org.ekstep.uploadfile' plugin, the request to send the CSV file will be { data : [file] }and notify the user if there are any errors from the error response and update the Text book unit attributes on success of api response}.
The settings of fineuploader plugin provides the option,
On success of the response
...
, read the getHeirarchy?mode=edit to get the updated attribute values of the textbook unit and assign it to data.
...
Pros:
...
Now dispatch the event `org.ekstep.collectioneditor:content:update`, with data from the getHierarchy result, the org.ekstep.contentMeta plugin will listen to the event and update the attributes of TOC
Pros:
Cons
Basic validations like empty record check is known after the api call.
...