@@ -224,14 +224,14 @@ def self.row_location_add(last_row_id, block_id, view_id)
224
224
"table" : "collection_view" ,
225
225
"id" : view_id ,
226
226
"path" : [
227
- "page_sort"
227
+ "page_sort" ,
228
228
] ,
229
229
"command" : "listAfter" ,
230
230
"args" : {
231
- "after" : last_row_id ,
232
- "id" : block_id
233
- }
234
- }
231
+ "after" : last_row_id ,
232
+ "id" : block_id ,
233
+ } ,
234
+ }
235
235
end
236
236
237
237
def self . block_location_remove ( block_parent_id , block_id )
@@ -459,6 +459,7 @@ def self.insert_data(block_id, column, value, mapping)
459
459
datetime_mappings = [ "date" ]
460
460
media_mappings = [ "file" ]
461
461
person_mappings = [ "person" ]
462
+ page_mappings = [ "relation" ]
462
463
463
464
table = "block"
464
465
path = [
@@ -475,10 +476,12 @@ def self.insert_data(block_id, column, value, mapping)
475
476
args = [ [ "‣" , [ [ "d" , { "type" : "date" , "start_date" : value } ] ] ] ]
476
477
elsif person_mappings . include? ( mapping )
477
478
args = [ [ "‣" ,
478
- [ [ "u" , value ] ]
479
- ] ]
480
- else
481
- raise SchemaTypeError , "Invalid property type: #{ mapping } "
479
+ [ [ "u" , value ] ] ] ]
480
+ elsif page_mappings . include? ( mapping )
481
+ args = [ [ "‣" ,
482
+ [ [ "p" , value ] ] ] ]
483
+ else
484
+ raise SchemaTypeError , "Invalid property type: #{ mapping } "
482
485
end
483
486
484
487
{
@@ -499,10 +502,10 @@ def self.add_new_option(column, value, collection_id)
499
502
500
503
args = {
501
504
"value" : {
502
- "id" : SecureRandom . hex ( 16 ) ,
503
- "value" : value ,
504
- "color" : random_color
505
- }
505
+ "id" : SecureRandom . hex ( 16 ) ,
506
+ "value" : value ,
507
+ "color" : random_color ,
508
+ } ,
506
509
}
507
510
508
511
{
@@ -593,10 +596,10 @@ def self.add_collection_property(collection_id, args)
593
596
"width" => 200 ,
594
597
} ,
595
598
{
596
- "property" => "phone" ,
597
- "visible" => true ,
598
- "width" => 200 ,
599
- } ,
599
+ "property" => "phone" ,
600
+ "visible" => true ,
601
+ "width" => 200 ,
602
+ } ,
600
603
{
601
604
"property" => "unicode_version" ,
602
605
"visible" => true ,
@@ -613,20 +616,28 @@ def self.add_collection_property(collection_id, args)
613
616
}
614
617
end
615
618
616
- def self . update_property_value ( page_id , column_name , new_value )
619
+ def self . update_property_value ( page_id , column_name , new_value , column_type )
617
620
# ! update the specified column_name to new_value
618
621
# ! page_id -> the ID of the page: ``str``
619
622
# ! column_name -> the name of the column ["property"] to update: ``str``
620
623
# ! new_value -> the new value to assign to that column ["property"]: ``str``
624
+ # ! column_type -> the type of the property: ``str``
621
625
table = "block"
622
626
path = [
623
627
"properties" ,
624
628
column_name ,
625
629
]
626
630
command = "set"
627
- args = [ [
628
- new_value ,
629
- ] ]
631
+
632
+ if column_type == "relation"
633
+ args = [ [ "‣" , [ [
634
+ "p" , new_value ,
635
+ ] ] ] ]
636
+ else
637
+ args = [ [
638
+ new_value ,
639
+ ] ]
640
+ end
630
641
631
642
{
632
643
id : page_id ,
@@ -639,7 +650,7 @@ def self.update_property_value(page_id, column_name, new_value)
639
650
end
640
651
641
652
class SchemaTypeError < StandardError
642
- def initialize ( msg = "Custom exception that is raised when an invalid property type is passed as a mapping." , exception_type = "schema_type" )
653
+ def initialize ( msg = "Custom exception that is raised when an invalid property type is passed as a mapping." , exception_type = "schema_type" )
643
654
@exception_type = exception_type
644
655
super ( msg )
645
656
end
@@ -665,4 +676,4 @@ def build_payload(operations, request_ids)
665
676
}
666
677
payload
667
678
end
668
- end
679
+ end
0 commit comments