After adding the tweak and restarting, do the following:
- Add the following custom action:
Code:
from calibre import prints
from calibre.constants import DEBUG
from calibre_plugins.action_chains.actions.single_field import SingleFieldAction, get_possible_cols
class SingleFieldActionModified(SingleFieldAction):
name = 'Modified Single Field Edit'
support_scopes = True
def run(self, gui, settings, chain):
db = gui.current_db
col_name = chain.chain_vars.get('_variant_argument')
if col_name in get_possible_cols(db):
settings['value_type'] = 'prompt'
settings['col_name'] = col_name
SingleFieldAction.run(self, gui, settings, chain)
else:
prints(f'ERROR: column name ({col_name}) is not valid')
def validate(self, settings):
return True
def config_widget(self):
return None
This action is a modification of the single edit that will let you edit at runtime a column. It reads the column name from a chain variable.
- Create a chain and add the action just added above (Modified Single Edit)
- In the Add/Modify Chain dialog, double click the chain > Chain Variations > add the following template
Code:
program:
columns = 'title,authors,tags,#genre';
for col in columns:
add_chain_variant('Edit ' & col, col, 'The name of the submenu')
rof
Change the columns variable to include the custom columns you want.
Now you should have a submenu with multiple chain variants, for each column you want.