brendo / bulkimporter

A Symphony extension to allow the bulk uploading of data
6 stars 1 forks source link

"Bridges" to support BiDirectional-Link and Select Box Link extensions #8

Open ahwayakchih opened 13 years ago

ahwayakchih commented 13 years ago

As requested at https://github.com/brendo/bulkimporter/pull/7#issuecomment-1129265 i'm opening new issue.

"Bridge" between SubsectionManager and Bulk Importer adds JavaScript on publish "edit"and "new" pages.

It selects SubsectionManager fields that point to section that has upload fields. Then, each "create" button (so only SubsectionManager fields that allow creating entries will be "upgraded") is changed so it contains "submenu" that looks similar (actually it is pretty much based on) the one from Dashboard extension.

"Submenu" contains two options:

  1. "Single entry" - clicking it is the same as clicking "create" button.
  2. "Bulk Import" - clicking it makes wonders ;).

"Bulk Import" option uses the same effect as regular "create" to open a drawer with iframe. But in this case, iframe points to Bulk Importer page, with options pre-selected according to setup of SubsectionManager field and currently edited entry's section. After Bulk Import is complete, drawer is closed and new items are selected in SubsectionManager field. End result is the same as if user added ("created") SubsectionManager items one by one.

Something similar could be done for Select Box Link and Bi-Link fields (tough a lot simpler, because they use simpler interfaces). I am not using any of them at the moment, so i did not include them in last patchset. But they are supported by Bulk Importer, so i think it would be nice to have such "bridge" for each of them too.

I am just not sure if such "bridges" should be enabled by default (BTW the one for SubsectionManager is always enabled, maybe it should be optional?), because those fields do not allow for "in-place" creation of entries they link to.

brendo commented 13 years ago

Got any screenshots? Or screencast?

I feel that should be optional, and not enabled by default. Perhaps these settings can be controlled from the Preferences page? Then again, the Bridge might only want to be on certain sections so the interface may become a little complex and better suited to a Bulk Importer standalone page.

Great idea though, you've really taken this extension and made it a lot easier to use, hat tip

ahwayakchih commented 13 years ago

Not sure if it is a proper way to post screenshots, but i created branch and uploaded screenshot there :).

might only want to be on certain sections so the interface may become a little complex and better suited to a Bulk Importer standalone page.

How about injecting checkbox to SubsectionManager field settings? I think that would be most flexible and allow us to drop ajax check on every page load (extension could output list of enabled fields to Symhony.Context, and JavaScript could simply use that instead of running AJAX call for each SubsectionManager field found on entry edit page).

Great idea though, you've really taken this extension and made it a lot easier to use, hat tip

Thanks, but it's all because of lapnotes.com project i am working on :).

brendo commented 13 years ago

Wow, that looks really handy! Thanks for the screenshot.

How about injecting checkbox to SubsectionManager field settings?

The problem with this approach is upon saving a Field Symphony will expect the Field to take care of saving our injected checkbox, which will ultimately fail because there won't be a column in the field's database table for our preference.

It could still work however, Javascript could remove the field on Submit and pass it off to our own handler to save the preference, but I wonder if it starts to set on too many people's toes and is a bit frail. This approach would require you to send a blocking AJAX call to our page to save the preference, and then allow Symphony to continue saving the fields. A main point of concern is that we only really want this to happen should the Section be saved successfully.

Perhaps we have to inject the Symphony.Context information on the Section Editor page, use the SectionPreCreate/SectionPreEdit delegates to remove our checkboxes and save them in localStorage and then listen for the SectionPostCreate/SectionPostEdit delegates and if successful, save our BI preferences then?

Could work!

ahwayakchih commented 13 years ago

The problem with this approach is upon saving a Field Symphony will expect the Field to take care of saving our injected checkbox, which will ultimately fail because there won't be a column in the field's database table for our preference.

With earlier versions of Symphony and markitup extension i used adminPagePostGenerate delegate and a lot of hacky code.

Now we have FieldPostCreate and FieldPostEdit delegates. Nothing should fail because fields do the saving themselves - Symphony does not do it automatically. Each field is called through setDataFromPost and then commit functions. Fields parse whatever data they need, and save it to database. Everything else is ignored :).

I already used this trick for autocompleter extension and did not encounter any problems so far (that does not mean there are none at all for sure, just that it's been tested with different configurations before :).

brendo commented 13 years ago

Ah excellent! Thanks for setting that straight.

Full steam ahead then I reckon, your approach sounds good.

ahwayakchih commented 13 years ago

OK, i will implement this on weekend.

brendo commented 13 years ago

I'd like to put these bridges in 1.0

For the immediate future though, I'd like to release 0.9.3 with the SSM bridge as a way to gauge some feedback from users which might be helpful to apply to the RL/SBL bridges.

ahwayakchih commented 13 years ago

Yes, that's what i was thinking too. I have to finish project stuff first before going for RL/SBL bridges (we do not use those fields, so i have no way to quickly test them with rest of the data), so inlcuding SSM bridge for now, and adding others later would be perfect for me.