mirror of
https://github.com/gristlabs/grist-core.git
synced 2026-03-02 04:09:24 +00:00
(core) Allow using negative rowIds to add records and refer to them in Reference values.
Summary: - When adding records, negative rowIds may now be specified. They'll be replaced by proper IDs. - If these negative IDs are used in Reference columns in subsequent actions in the same bundle of UserActions, they get replaced with the proper rowIds. - Use this to sync ACLResources and ACLRules from UI in a single batch of UserActions. - Resolve the TODOs in GranularAccess test, to no longer need to guess resource rowIds. Test Plan: Added a python unittest for mapping IDs; updated browser tests. Reviewers: paulfitz Reviewed By: paulfitz Differential Revision: https://phab.getgrist.com/D2691
This commit is contained in:
@@ -201,7 +201,7 @@ class BaseColumn(object):
|
||||
"""
|
||||
return self.type_obj.convert(value_to_convert)
|
||||
|
||||
def prepare_new_values(self, values, ignore_data=False):
|
||||
def prepare_new_values(self, values, ignore_data=False, action_summary=None):
|
||||
"""
|
||||
This allows us to modify values and also produce adjustments to existing records. This
|
||||
currently is only used by PositionColumn. Returns two lists: new_values, and
|
||||
@@ -281,7 +281,7 @@ class PositionColumn(NumericColumn):
|
||||
super(PositionColumn, self).copy_from_column(other_column)
|
||||
self._sorted_rows = SortedListWithKey(other_column._sorted_rows[:], key=self.raw_get)
|
||||
|
||||
def prepare_new_values(self, values, ignore_data=False):
|
||||
def prepare_new_values(self, values, ignore_data=False, action_summary=None):
|
||||
# This does the work of adjusting positions and relabeling existing rows with new position
|
||||
# (without changing sort order) to make space for the new positions. Note that this is also
|
||||
# used for updating a position for an existing row: we'll find a new value for it; later when
|
||||
@@ -356,6 +356,11 @@ class ReferenceColumn(BaseReferenceColumn):
|
||||
if new_value:
|
||||
self._relation.add_reference(row_id, new_value)
|
||||
|
||||
def prepare_new_values(self, values, ignore_data=False, action_summary=None):
|
||||
if action_summary and values:
|
||||
values = action_summary.translate_new_row_ids(self._target_table.table_id, values)
|
||||
return values, []
|
||||
|
||||
|
||||
class ReferenceListColumn(BaseReferenceColumn):
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user