From 364b4524f026c29f729528fd3ced8593fd806a10 Mon Sep 17 00:00:00 2001 From: Ami Patel Date: Thu, 3 Aug 2023 15:21:53 +0800 Subject: [PATCH 1/3] updated flowering_period and fruiting_period fields to select2 field --- .../species_and_communities/admin.py | 12 ++++- .../species_and_communities/models.py | 42 ++++++++++++--- .../species_and_communities/serializers.py | 8 ++- .../species_combine_profile.vue | 12 ++--- .../species_communities/species_profile.vue | 52 +++++++++++++++---- .../species_split/species_split_profile.vue | 12 ++--- boranga/migrations/0153_auto_20230803_1058.py | 49 +++++++++++++++++ boranga/migrations/0154_auto_20230803_1129.py | 23 ++++++++ boranga/migrations/0155_auto_20230803_1206.py | 23 ++++++++ boranga/migrations/0156_auto_20230803_1408.py | 23 ++++++++ 10 files changed, 225 insertions(+), 31 deletions(-) create mode 100644 boranga/migrations/0153_auto_20230803_1058.py create mode 100644 boranga/migrations/0154_auto_20230803_1129.py create mode 100644 boranga/migrations/0155_auto_20230803_1206.py create mode 100644 boranga/migrations/0156_auto_20230803_1408.py diff --git a/boranga/components/species_and_communities/admin.py b/boranga/components/species_and_communities/admin.py index 64b8fd46c..7c7cbf57d 100755 --- a/boranga/components/species_and_communities/admin.py +++ b/boranga/components/species_and_communities/admin.py @@ -43,6 +43,14 @@ class DocumentSubCategoryAdmin(admin.ModelAdmin): list_display = ['document_sub_category_name', 'document_category'] +@admin.register(FloweringPeriod) +class FloweringPeriodAdmin(admin.ModelAdmin): + list_display = ['period'] + +@admin.register(FruitingPeriod) +class FruitingPeriodAdmin(admin.ModelAdmin): + list_display = ['period'] + # Each of the following models will be available to Django Admin. admin.site.register(GroupType) admin.site.register(Region) @@ -55,8 +63,8 @@ class DocumentSubCategoryAdmin(admin.ModelAdmin): admin.site.register(PhylogeneticGroup) admin.site.register(Genus) admin.site.register(Kingdom) -admin.site.register(FloweringPeriod) -admin.site.register(FruitingPeriod) +# admin.site.register(FloweringPeriod) +# admin.site.register(FruitingPeriod) admin.site.register(FloraRecruitmentType) # admin.site.register(SeedViabilityGerminationInfo) admin.site.register(RootMorphology) diff --git a/boranga/components/species_and_communities/models.py b/boranga/components/species_and_communities/models.py index 6a7defa93..dcafa3cc8 100644 --- a/boranga/components/species_and_communities/models.py +++ b/boranga/components/species_and_communities/models.py @@ -1867,11 +1867,26 @@ class FloweringPeriod(models.Model): - SpeciesConservationAttributes """ - period = models.CharField(max_length=200, blank=False, unique=True) + PERIOD_CHOICES = ( + ('January', 'January'), + ('February', 'February'), + ('March', 'March'), + ('April', 'April'), + ('May', 'May'), + ('June', 'June'), + ('July', 'July'), + ('August', 'August'), + ('September', 'September'), + ('October', 'October'), + ('November', 'November'), + ('December', 'December'), + ) + + period = models.CharField(max_length=200, blank=False, unique=True, choices=PERIOD_CHOICES) class Meta: app_label = 'boranga' - ordering = ['period'] + # ordering = ['period'] def __str__(self): return str(self.period) @@ -1885,11 +1900,26 @@ class FruitingPeriod(models.Model): - SpeciesConservationAttributes """ - period = models.CharField(max_length=200, blank=False, unique=True) + PERIOD_CHOICES = ( + ('January', 'January'), + ('February', 'February'), + ('March', 'March'), + ('April', 'April'), + ('May', 'May'), + ('June', 'June'), + ('July', 'July'), + ('August', 'August'), + ('September', 'September'), + ('October', 'October'), + ('November', 'November'), + ('December', 'December'), + ) + + period = models.CharField(max_length=200, blank=False, unique=True, choices=PERIOD_CHOICES) class Meta: app_label = 'boranga' - ordering = ['period'] + # ordering = ['period'] def __str__(self): return str(self.period) @@ -2035,8 +2065,8 @@ class SpeciesConservationAttributes(models.Model): species = models.ForeignKey(Species, on_delete=models.CASCADE, unique=True, null=True, related_name="species_conservation_attributes") # flora related attributes - flowering_period = models.ForeignKey(FloweringPeriod, on_delete=models.SET_NULL, null=True, blank=True) - fruiting_period = models.ForeignKey(FruitingPeriod, on_delete=models.SET_NULL, null=True, blank=True) + flowering_period = models.ManyToManyField(FloweringPeriod, blank=True, null=True, related_name="curr_flowering_period") + fruiting_period = models.ManyToManyField(FruitingPeriod, blank=True, null=True, related_name="curr_fruiting_period") flora_recruitment_type = models.ForeignKey(FloraRecruitmentType, on_delete=models.SET_NULL, null=True, blank=True) flora_recruitment_notes = models.CharField(max_length=1000,null=True, blank=True) seed_viability_germination_info = models.CharField(max_length=1000,null=True, blank=True) diff --git a/boranga/components/species_and_communities/serializers.py b/boranga/components/species_and_communities/serializers.py index cbc03e172..17eea3986 100755 --- a/boranga/components/species_and_communities/serializers.py +++ b/boranga/components/species_and_communities/serializers.py @@ -337,8 +337,10 @@ class Meta: 'id', 'species_id', #flora related attributes - 'flowering_period_id', - 'fruiting_period_id', + # 'flowering_period_id', + # 'fruiting_period_id', + 'flowering_period', + 'fruiting_period', 'flora_recruitment_type_id', 'flora_recruitment_notes', 'seed_viability_germination_info', @@ -383,6 +385,8 @@ class Meta: #flora related attributes 'flowering_period_id', 'fruiting_period_id', + 'flowering_period', + 'fruiting_period', 'flora_recruitment_type_id', 'flora_recruitment_notes', 'seed_viability_germination_info', diff --git a/boranga/frontend/boranga/src/components/common/species_communities/species_combine/species_combine_profile.vue b/boranga/frontend/boranga/src/components/common/species_communities/species_combine/species_combine_profile.vue index 191cefd74..7685a4ea5 100644 --- a/boranga/frontend/boranga/src/components/common/species_communities/species_combine/species_combine_profile.vue +++ b/boranga/frontend/boranga/src/components/common/species_communities/species_combine/species_combine_profile.vue @@ -216,7 +216,7 @@
+ @change="checkConservationInput('flowering_prd_chk','flowering_prd_chk'+species.id,'flowering_period',species.conservation_attributes.flowering_period)" />
@@ -232,7 +232,7 @@
+ v-model="species.conservation_attributes.fruiting_period"> @@ -253,7 +253,7 @@
+ @change="checkConservationInput('fruiting_prd_chk','fruiting_prd_chk'+species.id,'fruiting_period',species.conservation_attributes.fruiting_period)" />
@@ -261,7 +261,7 @@
-
@@ -219,10 +221,12 @@
- +
@@ -714,6 +718,36 @@ export default { } }, eventListeners:function (){ + let vm = this; + $(vm.$refs.flowering_period_select).select2({ + "theme": "bootstrap-5", + allowClear: true, + placeholder:"Select Flowering Period", + multiple: true, + }). + on("select2:select",function (e) { + var selected = $(e.currentTarget); + vm.species_community.conservation_attributes.flowering_period = selected.val(); + }). + on("select2:unselect",function (e) { + var selected = $(e.currentTarget); + vm.species_community.conservation_attributes.flowering_period = selected.val(); + }); + + $(vm.$refs.fruiting_period_select).select2({ + "theme": "bootstrap-5", + allowClear: true, + placeholder:"Select Fruiting Period", + multiple: true, + }). + on("select2:select",function (e) { + var selected = $(e.currentTarget); + vm.species_community.conservation_attributes.fruiting_period = selected.val(); + }). + on("select2:unselect",function (e) { + var selected = $(e.currentTarget); + vm.species_community.conservation_attributes.fruiting_period = selected.val(); + }); }, }, created: async function() { @@ -813,7 +847,7 @@ export default { }, mounted: function(){ let vm = this; - //vm.eventListeners(); + vm.eventListeners(); vm.initialiseScientificNameLookup(); vm.loadTaxonomydetails(); } diff --git a/boranga/frontend/boranga/src/components/common/species_communities/species_split/species_split_profile.vue b/boranga/frontend/boranga/src/components/common/species_communities/species_split/species_split_profile.vue index a1d78cad5..247c0252c 100644 --- a/boranga/frontend/boranga/src/components/common/species_communities/species_split/species_split_profile.vue +++ b/boranga/frontend/boranga/src/components/common/species_communities/species_split/species_split_profile.vue @@ -212,21 +212,21 @@
- +
+ v-model="species_original.conservation_attributes.fruiting_period">
- +
@@ -253,7 +253,7 @@
@@ -142,7 +142,7 @@
- +
diff --git a/boranga/frontend/boranga/src/components/common/species_communities/species_combine/species_combine_profile.vue b/boranga/frontend/boranga/src/components/common/species_communities/species_combine/species_combine_profile.vue index 7685a4ea5..401e647fb 100644 --- a/boranga/frontend/boranga/src/components/common/species_communities/species_combine/species_combine_profile.vue +++ b/boranga/frontend/boranga/src/components/common/species_communities/species_combine/species_combine_profile.vue @@ -150,7 +150,7 @@
- +
diff --git a/boranga/frontend/boranga/src/components/common/species_communities/species_profile.vue b/boranga/frontend/boranga/src/components/common/species_communities/species_profile.vue index d2563d25d..d05d6083f 100644 --- a/boranga/frontend/boranga/src/components/common/species_communities/species_profile.vue +++ b/boranga/frontend/boranga/src/components/common/species_communities/species_profile.vue @@ -152,32 +152,32 @@
- +
+ class="aoo_auto form-check-input" name="aoo_auto" v-model="species_community.distribution.aoo_auto"> + class="aoo_auto form-check-input" name="aoo_auto" v-model="species_community.distribution.aoo_auto">
- +
- +
+ class="aoo_actual_auto form-check-input" name="aoo_actual_auto" + v-model="species_community.distribution.aoo_actual_auto"> + class="aoo_actual_auto form-check-input" name="aoo_actual_auto" + v-model="species_community.distribution.aoo_actual_auto">
@@ -218,6 +218,25 @@
+
+ +
+ + +
+
@@ -507,6 +526,7 @@ export default { }, scientific_name_lookup: 'scientific_name_lookup' + vm._uid, select_scientific_name: "select_scientific_name"+ vm._uid, + select_flowering_period: "select_flowering_period"+ vm._uid, taxonBody: 'taxonBody' + vm._uid, distributionBody: 'distributionBody' + vm._uid, conservationBody: 'conservationBody' + vm._uid, @@ -541,6 +561,19 @@ export default { genus_id: null, name_authority: null, name_comments: null, + period_list: [{value: 'january', name: 'January'}, + {value: 'february', name: 'February'}, + {value: 'march', name: 'March'}, + {value: 'april', name: 'April'}, + {value: 'may', name: 'May'}, + {value: 'june', name: 'June'}, + {value: 'july', name: 'July'}, + {value: 'august', name: 'August'}, + {value: 'september', name: 'September'}, + {value: 'october', name: 'October'}, + {value: 'november', name: 'November'}, + {value: 'december', name: 'December'}, + ], } }, components: { @@ -718,36 +751,6 @@ export default { } }, eventListeners:function (){ - let vm = this; - $(vm.$refs.flowering_period_select).select2({ - "theme": "bootstrap-5", - allowClear: true, - placeholder:"Select Flowering Period", - multiple: true, - }). - on("select2:select",function (e) { - var selected = $(e.currentTarget); - vm.species_community.conservation_attributes.flowering_period = selected.val(); - }). - on("select2:unselect",function (e) { - var selected = $(e.currentTarget); - vm.species_community.conservation_attributes.flowering_period = selected.val(); - }); - - $(vm.$refs.fruiting_period_select).select2({ - "theme": "bootstrap-5", - allowClear: true, - placeholder:"Select Fruiting Period", - multiple: true, - }). - on("select2:select",function (e) { - var selected = $(e.currentTarget); - vm.species_community.conservation_attributes.fruiting_period = selected.val(); - }). - on("select2:unselect",function (e) { - var selected = $(e.currentTarget); - vm.species_community.conservation_attributes.fruiting_period = selected.val(); - }); }, }, created: async function() { diff --git a/boranga/frontend/boranga/src/components/common/species_communities/species_split/species_split_profile.vue b/boranga/frontend/boranga/src/components/common/species_communities/species_split/species_split_profile.vue index 247c0252c..3dc01edc5 100644 --- a/boranga/frontend/boranga/src/components/common/species_communities/species_split/species_split_profile.vue +++ b/boranga/frontend/boranga/src/components/common/species_communities/species_split/species_split_profile.vue @@ -150,7 +150,7 @@
- +
@@ -167,7 +167,7 @@
- +
diff --git a/boranga/migrations/0154_speciesconservationattributes_flowering_prd.py b/boranga/migrations/0154_speciesconservationattributes_flowering_prd.py new file mode 100644 index 000000000..fa6095aca --- /dev/null +++ b/boranga/migrations/0154_speciesconservationattributes_flowering_prd.py @@ -0,0 +1,19 @@ +# Generated by Django 3.2.20 on 2023-08-03 03:42 + +from django.db import migrations +import multiselectfield.db.fields + + +class Migration(migrations.Migration): + + dependencies = [ + ('boranga', '0153_auto_20230802_1034'), + ] + + operations = [ + migrations.AddField( + model_name='speciesconservationattributes', + name='flowering_prd', + field=multiselectfield.db.fields.MultiSelectField(blank=True, choices=[('january', 'January'), ('february', 'February'), ('march', 'March')], max_length=250, null=True), + ), + ] From a5b7a72d28047f1f67585018f7f887222d508a75 Mon Sep 17 00:00:00 2001 From: Ami Patel Date: Tue, 8 Aug 2023 17:26:19 +0800 Subject: [PATCH 3/3] altered three flora fields to multiplechoicefield and added select2 for those in FE species split and combine --- .../species_and_communities/models.py | 51 ++--- .../species_and_communities/serializers.py | 21 +-- .../species_combine_profile.vue | 175 ++++++++++++++---- .../species_communities/species_profile.vue | 115 ++++++------ .../species_split/species_split_profile.vue | 175 ++++++++++++++---- .../migrations/0157_merge_20230808_1016.py | 14 ++ boranga/migrations/0158_auto_20230808_1029.py | 42 +++++ boranga/migrations/0159_auto_20230808_1042.py | 28 +++ ...sconservationattributes_breeding_period.py | 19 ++ boranga/migrations/0161_auto_20230808_1201.py | 22 +++ 10 files changed, 484 insertions(+), 178 deletions(-) create mode 100644 boranga/migrations/0157_merge_20230808_1016.py create mode 100644 boranga/migrations/0158_auto_20230808_1029.py create mode 100644 boranga/migrations/0159_auto_20230808_1042.py create mode 100644 boranga/migrations/0160_alter_speciesconservationattributes_breeding_period.py create mode 100644 boranga/migrations/0161_auto_20230808_1201.py diff --git a/boranga/components/species_and_communities/models.py b/boranga/components/species_and_communities/models.py index c93a1bf23..6eea1392e 100644 --- a/boranga/components/species_and_communities/models.py +++ b/boranga/components/species_and_communities/models.py @@ -1926,22 +1926,8 @@ class FruitingPeriod(models.Model): - SpeciesConservationAttributes """ - PERIOD_CHOICES = ( - ('January', 'January'), - ('February', 'February'), - ('March', 'March'), - ('April', 'April'), - ('May', 'May'), - ('June', 'June'), - ('July', 'July'), - ('August', 'August'), - ('September', 'September'), - ('October', 'October'), - ('November', 'November'), - ('December', 'December'), - ) - period = models.CharField(max_length=200, blank=False, unique=True, choices=PERIOD_CHOICES) + period = models.CharField(max_length=200, blank=False, unique=True, choices=FloweringPeriod.PERIOD_CHOICES) class Meta: app_label = 'boranga' @@ -2051,11 +2037,11 @@ class BreedingPeriod(models.Model): - SpeciesConservationAttributes """ - period = models.CharField(max_length=200, blank=False, unique=True) + period = models.CharField(max_length=200, blank=False, unique=True, choices=FloweringPeriod.PERIOD_CHOICES) class Meta: app_label = 'boranga' - ordering = ['period'] + # ordering = ['period'] def __str__(self): return str(self.period) @@ -2088,26 +2074,25 @@ class SpeciesConservationAttributes(models.Model): Is: - Table """ - PERIOD_CHOICES = (('january', 'January'), - ('february', 'February'), - ('march', 'March'), - ('april', 'April'), - ('may', 'May'), - ('june', 'June'), - ('july', 'July'), - ('august', 'August'), - ('september', 'September'), - ('october', 'October'), - ('november', 'November'), - ('december', 'December'), + PERIOD_CHOICES = ((1, 'January'), + (2, 'February'), + (3, 'March'), + (4, 'April'), + (5, 'May'), + (6, 'June'), + (7, 'July'), + (8, 'August'), + (9, 'September'), + (10, 'October'), + (11, 'November'), + (12, 'December'), ) species = models.ForeignKey(Species, on_delete=models.CASCADE, unique=True, null=True, related_name="species_conservation_attributes") # flora related attributes - flowering_period = models.ForeignKey(FloweringPeriod, on_delete=models.SET_NULL, null=True, blank=True) - flowering_prd = MultiSelectField(max_length=250, blank=True, choices=PERIOD_CHOICES, null=True) - fruiting_period = models.ForeignKey(FruitingPeriod, on_delete=models.SET_NULL, null=True, blank=True) + flowering_period = MultiSelectField(max_length=250, blank=True, choices=PERIOD_CHOICES, null=True) + fruiting_period = MultiSelectField(max_length=250, blank=True, choices=PERIOD_CHOICES, null=True) flora_recruitment_type = models.ForeignKey(FloraRecruitmentType, on_delete=models.SET_NULL, null=True, blank=True) flora_recruitment_notes = models.CharField(max_length=1000,null=True, blank=True) seed_viability_germination_info = models.CharField(max_length=1000,null=True, blank=True) @@ -2116,7 +2101,7 @@ class SpeciesConservationAttributes(models.Model): response_to_dieback = models.CharField(max_length=1500, null=True, blank=True) # fauna related attributes - breeding_period = models.ForeignKey(BreedingPeriod, on_delete=models.SET_NULL, null=True, blank=True) + breeding_period = MultiSelectField(max_length=250, blank=True, choices=PERIOD_CHOICES, null=True) fauna_breeding = models.CharField(max_length=2000,null=True, blank=True) fauna_reproductive_capacity = models.CharField(max_length=200,null=True, blank=True) diet_and_food_source = models.CharField(max_length=500, null=True, blank=True) diff --git a/boranga/components/species_and_communities/serializers.py b/boranga/components/species_and_communities/serializers.py index faaf2a6a1..c879677e4 100755 --- a/boranga/components/species_and_communities/serializers.py +++ b/boranga/components/species_and_communities/serializers.py @@ -342,9 +342,8 @@ class Meta: 'id', 'species_id', #flora related attributes - 'flowering_period_id', - 'flowering_prd', - 'fruiting_period_id', + 'flowering_period', + 'fruiting_period', 'flora_recruitment_type_id', 'flora_recruitment_notes', 'seed_viability_germination_info', @@ -353,7 +352,7 @@ class Meta: 'hydrology', 'response_to_dieback', # fauna related attributes - 'breeding_period_id', + 'breeding_period', 'fauna_breeding', 'fauna_reproductive_capacity', 'diet_and_food_source', @@ -377,17 +376,16 @@ def __init__(self, *args, **kwargs): PERIOD_CHOICES = [] for rs in SpeciesConservationAttributes.PERIOD_CHOICES: PERIOD_CHOICES.append(([rs[0], rs[1]])) - self.fields['flowering_prd'] = serializers.MultipleChoiceField(choices=PERIOD_CHOICES, allow_blank=False) + self.fields['flowering_period', 'fruiting_period', 'breeding_period'] = serializers.MultipleChoiceField(choices=PERIOD_CHOICES, allow_blank=False) class SaveSpeciesConservationAttributesSerializer(serializers.ModelSerializer): species_id = serializers.IntegerField(required=False, allow_null=True, write_only= True) - flowering_period_id = serializers.IntegerField(required=False, allow_null=True, write_only= True) - flowering_prd = serializers.MultipleChoiceField(choices=SpeciesConservationAttributes.PERIOD_CHOICES, allow_null=True, allow_blank=True, required=False) - fruiting_period_id = serializers.IntegerField(required=False, allow_null=True, write_only= True) + flowering_period = serializers.MultipleChoiceField(choices=SpeciesConservationAttributes.PERIOD_CHOICES, allow_null=True, allow_blank=True, required=False) + fruiting_period = serializers.MultipleChoiceField(choices=SpeciesConservationAttributes.PERIOD_CHOICES, allow_null=True, allow_blank=True, required=False) flora_recruitment_type_id = serializers.IntegerField(required=False, allow_null=True, write_only= True) root_morphology_id = serializers.IntegerField(required=False, allow_null=True, write_only= True) - breeding_period_id = serializers.IntegerField(required=False, allow_null=True, write_only= True) + breeding_period = serializers.MultipleChoiceField(choices=SpeciesConservationAttributes.PERIOD_CHOICES, allow_null=True, allow_blank=True, required=False) post_fire_habitat_interaction_id = serializers.IntegerField(required=False, allow_null=True, write_only= True) class Meta: model = SpeciesConservationAttributes @@ -395,9 +393,6 @@ class Meta: 'id', 'species_id', #flora related attributes - 'flowering_period_id', - 'flowering_prd', - 'fruiting_period_id', 'flowering_period', 'fruiting_period', 'flora_recruitment_type_id', @@ -408,7 +403,7 @@ class Meta: 'hydrology', 'response_to_dieback', # fauna related attributes - 'breeding_period_id', + 'breeding_period', 'fauna_breeding', 'fauna_reproductive_capacity', 'diet_and_food_source', diff --git a/boranga/frontend/boranga/src/components/common/species_communities/species_combine/species_combine_profile.vue b/boranga/frontend/boranga/src/components/common/species_communities/species_combine/species_combine_profile.vue index 401e647fb..262f8559b 100644 --- a/boranga/frontend/boranga/src/components/common/species_communities/species_combine/species_combine_profile.vue +++ b/boranga/frontend/boranga/src/components/common/species_communities/species_combine/species_combine_profile.vue @@ -214,27 +214,31 @@
-
- +
+ @change="checkConservationInput('flowering_prd_chk','flowering_prd_chk'+species.id,'flowering_period',species.conservation_attributes.flowering_period, 'flowering_period_select')" />
-
- +
@@ -243,27 +247,31 @@
-
- +
+ @change="checkConservationInput('fruiting_prd_chk','fruiting_prd_chk'+species.id,'fruiting_period',species.conservation_attributes.fruiting_period, 'fruiting_period_select')" />
-
- +
@@ -421,27 +429,31 @@
-
- +
+ @change="checkConservationInput('breeding_prd_chk','breeding_prd_chk'+species.id,'breeding_period', species.conservation_attributes.breeding_period, 'breeding_period_select')" />
-
- +
@@ -907,6 +919,12 @@ export default { return{ scientific_name_lookup: 'scientific_name_lookup' + vm.species_community.id, select_scientific_name: "select_scientific_name"+ vm.species_community.id, + select_flowering_period: "select_flowering_period"+ vm.species_community.id, + select_flowering_period_readonly: "select_flowering_period_readonly"+ vm.species_community.id, + select_fruiting_period: "select_fruiting_period"+ vm.species_community.id, + select_fruiting_period_readonly: "select_fruiting_period_readonly"+ vm.species_community.id, + select_breeding_period: "select_breeding_period"+ vm.species_community.id, + select_breeding_period_readonly: "select_breeding_period_readonly"+ vm.species_community.id, taxonBody: 'taxonBody' + vm._uid, distributionBody: 'distributionBody' + vm._uid, conservationBody: 'conservationBody' + vm._uid, @@ -940,6 +958,19 @@ export default { genus_id: null, name_authority: null, name_comments: null, + period_list: [{id: 1, name: 'January'}, + {id: 2, name: 'February'}, + {id: 3, name: 'March'}, + {id: 4, name: 'April'}, + {id: 5, name: 'May'}, + {id: 6, name: 'June'}, + {id: 7, name: 'July'}, + {id: 8, name: 'August'}, + {id: 9, name: 'September'}, + {id: 10, name: 'October'}, + {id: 11, name: 'November'}, + {id: 12, name: 'December'}, + ], } }, components: { @@ -1113,12 +1144,19 @@ export default { this.species_community.conservation_attributes.habitat_growth_form=null; } }, - checkConservationInput: function(chkbox_name,chkbox_id,obj_field,value){ + checkConservationInput: function(chkbox_name,chkbox_id,obj_field,value,select2_ref=""){ // if checkbox is checked copy value from original species to new species if($("#"+chkbox_id).is(':checked')== true){ this.species_community.conservation_attributes[obj_field] = value; + if(select2_ref != ""){ + $(this.$refs[select2_ref]).val(value).trigger("change"); + } }else{ this.species_community.conservation_attributes[obj_field]=null; + if(select2_ref != ""){ + $(this.$refs[select2_ref]).val("").trigger("change"); + this.species_community.conservation_attributes[obj_field] = []; + } } //--- to select only one checkbox at a time in a group let chkbox_name_arr=document.getElementsByName(chkbox_name); @@ -1166,6 +1204,73 @@ export default { }, //---------------------------------------------------------------- eventListeners:function (){ + let vm = this; + $(vm.$refs.flowering_period_select).select2({ + dropdownParent: $("#"+vm.select_flowering_period), + "theme": "bootstrap-5", + allowClear: true, + placeholder:"Select Flowering Period", + multiple: true, + }). + on("select2:select",function (e) { + var selected = $(e.currentTarget); + vm.species_community.conservation_attributes.flowering_period = selected.val(); + }). + on("select2:unselect",function (e) { + var selected = $(e.currentTarget); + vm.species_community.conservation_attributes.flowering_period = selected.val(); + }); + $(vm.$refs.flowering_period_select_readonly).select2({ + dropdownParent: $("#"+vm.select_flowering_period_readonly), + "theme": "bootstrap-5", + allowClear: true, + placeholder:"Select Flowering Period", + multiple: true, + }); + $(vm.$refs.fruiting_period_select).select2({ + dropdownParent: $("#"+vm.select_fruiting_period), + "theme": "bootstrap-5", + allowClear: true, + placeholder:"Select Fruiting Period", + multiple: true, + }). + on("select2:select",function (e) { + var selected = $(e.currentTarget); + vm.species_community.conservation_attributes.fruiting_period = selected.val(); + }). + on("select2:unselect",function (e) { + var selected = $(e.currentTarget); + vm.species_community.conservation_attributes.fruiting_period = selected.val(); + }); + $(vm.$refs.fruiting_period_select_readonly).select2({ + dropdownParent: $("#"+vm.select_fruiting_period_readonly), + "theme": "bootstrap-5", + allowClear: true, + placeholder:"Select Fruiting Period", + multiple: true, + }); + $(vm.$refs.breeding_period_select).select2({ + dropdownParent: $("#"+vm.select_breeding_period), + "theme": "bootstrap-5", + allowClear: true, + placeholder:"Select Breeding Period", + multiple: true, + }). + on("select2:select",function (e) { + var selected = $(e.currentTarget); + vm.species_community.conservation_attributes.breeding_period = selected.val(); + }). + on("select2:unselect",function (e) { + var selected = $(e.currentTarget); + vm.species_community.conservation_attributes.breeding_period = selected.val(); + }); + $(vm.$refs.breeding_period_select_readonly).select2({ + dropdownParent: $("#"+vm.select_breeding_period_readonly), + "theme": "bootstrap-5", + allowClear: true, + placeholder:"Select Breeding Period", + multiple: true, + }); }, }, created: async function() { @@ -1265,7 +1370,7 @@ export default { }, mounted: function(){ let vm = this; - //vm.eventListeners(); + vm.eventListeners(); vm.initialiseScientificNameLookup(); vm.loadTaxonomydetails(); } diff --git a/boranga/frontend/boranga/src/components/common/species_communities/species_profile.vue b/boranga/frontend/boranga/src/components/common/species_communities/species_profile.vue index 1b17af96d..1222edc52 100644 --- a/boranga/frontend/boranga/src/components/common/species_communities/species_profile.vue +++ b/boranga/frontend/boranga/src/components/common/species_communities/species_profile.vue @@ -212,50 +212,12 @@ style="width:100%;" class="form-select input-sm" multiple ref="flowering_period_select" v-model="species_community.conservation_attributes.flowering_period" > -
-
- -
- - -
-
-
- -
- - -
-
@@ -263,7 +225,7 @@ style="width:100%;" class="form-select input-sm" multiple ref="fruiting_period_select" v-model="species_community.conservation_attributes.fruiting_period" > - @@ -338,10 +300,12 @@
- +
@@ -580,18 +544,18 @@ export default { genus_id: null, name_authority: null, name_comments: null, - period_list: [{value: 'january', name: 'January'}, - {value: 'february', name: 'February'}, - {value: 'march', name: 'March'}, - {value: 'april', name: 'April'}, - {value: 'may', name: 'May'}, - {value: 'june', name: 'June'}, - {value: 'july', name: 'July'}, - {value: 'august', name: 'August'}, - {value: 'september', name: 'September'}, - {value: 'october', name: 'October'}, - {value: 'november', name: 'November'}, - {value: 'december', name: 'December'}, + period_list: [{id: 1, name: 'January'}, + {id: 2, name: 'February'}, + {id: 3, name: 'March'}, + {id: 4, name: 'April'}, + {id: 5, name: 'May'}, + {id: 6, name: 'June'}, + {id: 7, name: 'July'}, + {id: 8, name: 'August'}, + {id: 9, name: 'September'}, + {id: 10, name: 'October'}, + {id: 11, name: 'November'}, + {id: 12, name: 'December'}, ], } }, @@ -770,21 +734,48 @@ export default { } }, eventListeners:function (){ - let vm=this; - // Initialise select2 for proposed Conservation Criteria - $(vm.$refs.flowering_period).select2({ + let vm = this; + $(vm.$refs.flowering_period_select).select2({ + "theme": "bootstrap-5", + allowClear: true, + placeholder:"Select Flowering Period", + multiple: true, + }). + on("select2:select",function (e) { + var selected = $(e.currentTarget); + vm.species_community.conservation_attributes.flowering_period = selected.val(); + }). + on("select2:unselect",function (e) { + var selected = $(e.currentTarget); + vm.species_community.conservation_attributes.flowering_period = selected.val(); + }); + $(vm.$refs.fruiting_period_select).select2({ + "theme": "bootstrap-5", + allowClear: true, + placeholder:"Select Fruiting Period", + multiple: true, + }). + on("select2:select",function (e) { + var selected = $(e.currentTarget); + vm.species_community.conservation_attributes.fruiting_period = selected.val(); + }). + on("select2:unselect",function (e) { + var selected = $(e.currentTarget); + vm.species_community.conservation_attributes.fruiting_period = selected.val(); + }); + $(vm.$refs.breeding_period_select).select2({ "theme": "bootstrap-5", allowClear: true, - placeholder:"Select Period", + placeholder:"Select Breeding Period", multiple: true, }). on("select2:select",function (e) { var selected = $(e.currentTarget); - vm.species_community.conservation_attributes.flowering_prd = selected.val(); + vm.species_community.conservation_attributes.breeding_period = selected.val(); }). on("select2:unselect",function (e) { var selected = $(e.currentTarget); - vm.species_community.conservation_attributes.flowering_prd = selected.val(); + vm.species_community.conservation_attributes.breeding_period = selected.val(); }); }, }, diff --git a/boranga/frontend/boranga/src/components/common/species_communities/species_split/species_split_profile.vue b/boranga/frontend/boranga/src/components/common/species_communities/species_split/species_split_profile.vue index 3dc01edc5..148977850 100644 --- a/boranga/frontend/boranga/src/components/common/species_communities/species_split/species_split_profile.vue +++ b/boranga/frontend/boranga/src/components/common/species_communities/species_split/species_split_profile.vue @@ -210,25 +210,29 @@
-
- +
- +
-
- +
@@ -236,26 +240,30 @@
-
- +
- +
-
- +
@@ -395,25 +403,29 @@
-
- +
- +
-
- +
@@ -828,6 +840,12 @@ export default { return{ scientific_name_lookup: 'scientific_name_lookup' + vm.species_community.id, select_scientific_name: "select_scientific_name"+ vm.species_community.id, + select_flowering_period: "select_flowering_period"+ vm.species_community.id, + select_flowering_period_readonly: "select_flowering_period_readonly"+ vm.species_community.id, + select_fruiting_period: "select_fruiting_period"+ vm.species_community.id, + select_fruiting_period_readonly: "select_fruiting_period_readonly"+ vm.species_community.id, + select_breeding_period: "select_breeding_period"+ vm.species_community.id, + select_breeding_period_readonly: "select_breeding_period_readonly"+ vm.species_community.id, taxonBody: 'taxonBody' + vm._uid, distributionBody: 'distributionBody' + vm._uid, conservationBody: 'conservationBody' + vm._uid, @@ -861,6 +879,19 @@ export default { genus_id: null, name_authority: null, name_comments: null, + period_list: [{id: 1, name: 'January'}, + {id: 2, name: 'February'}, + {id: 3, name: 'March'}, + {id: 4, name: 'April'}, + {id: 5, name: 'May'}, + {id: 6, name: 'June'}, + {id: 7, name: 'July'}, + {id: 8, name: 'August'}, + {id: 9, name: 'September'}, + {id: 10, name: 'October'}, + {id: 11, name: 'November'}, + {id: 12, name: 'December'}, + ], } }, components: { @@ -1034,12 +1065,19 @@ export default { this.species_community.conservation_attributes.habitat_growth_form=null; } }, - checkConservationInput: function(chkbox,obj_field){ + checkConservationInput: function(chkbox,obj_field,select2_ref=""){ // if checkbox is checked copy value from original species to new species if($("#"+chkbox).is(':checked')== true){ this.species_community.conservation_attributes[obj_field] = this.species_original.conservation_attributes[obj_field]; + if(select2_ref != ""){ + $(this.$refs[select2_ref]).val(this.species_community.conservation_attributes[obj_field]).trigger("change"); + } }else{ this.species_community.conservation_attributes[obj_field]=null; + if(select2_ref != ""){ + $(this.$refs[select2_ref]).val("").trigger("change"); + this.species_community.conservation_attributes[obj_field]=[]; + } } }, checkDistributionInput: function(chkbox,obj_field){ @@ -1060,6 +1098,73 @@ export default { }, //---------------------------------------------------------------- eventListeners:function (){ + let vm = this; + $(vm.$refs.flowering_period_select).select2({ + dropdownParent: $("#"+vm.select_flowering_period), + "theme": "bootstrap-5", + allowClear: true, + placeholder:"Select Flowering Period", + multiple: true, + }). + on("select2:select",function (e) { + var selected = $(e.currentTarget); + vm.species_community.conservation_attributes.flowering_period = selected.val(); + }). + on("select2:unselect",function (e) { + var selected = $(e.currentTarget); + vm.species_community.conservation_attributes.flowering_period = selected.val(); + }); + $(vm.$refs.flowering_period_select_readonly).select2({ + dropdownParent: $("#"+vm.select_flowering_period_readonly), + "theme": "bootstrap-5", + allowClear: true, + placeholder:"Select Flowering Period", + multiple: true, + }); + $(vm.$refs.fruiting_period_select).select2({ + dropdownParent: $("#"+vm.select_fruiting_period), + "theme": "bootstrap-5", + allowClear: true, + placeholder:"Select Fruiting Period", + multiple: true, + }). + on("select2:select",function (e) { + var selected = $(e.currentTarget); + vm.species_community.conservation_attributes.fruiting_period = selected.val(); + }). + on("select2:unselect",function (e) { + var selected = $(e.currentTarget); + vm.species_community.conservation_attributes.fruiting_period = selected.val(); + }); + $(vm.$refs.fruiting_period_select_readonly).select2({ + dropdownParent: $("#"+vm.select_fruiting_period_readonly), + "theme": "bootstrap-5", + allowClear: true, + placeholder:"Select Fruiting Period", + multiple: true, + }); + $(vm.$refs.breeding_period_select).select2({ + dropdownParent: $("#"+vm.select_breeding_period), + "theme": "bootstrap-5", + allowClear: true, + placeholder:"Select Breeding Period", + multiple: true, + }). + on("select2:select",function (e) { + var selected = $(e.currentTarget); + vm.species_community.conservation_attributes.breeding_period = selected.val(); + }). + on("select2:unselect",function (e) { + var selected = $(e.currentTarget); + vm.species_community.conservation_attributes.breeding_period = selected.val(); + }); + $(vm.$refs.breeding_period_select_readonly).select2({ + dropdownParent: $("#"+vm.select_breeding_period_readonly), + "theme": "bootstrap-5", + allowClear: true, + placeholder:"Select Breeding Period", + multiple: true, + }); }, }, created: async function() { @@ -1159,7 +1264,7 @@ export default { }, mounted: function(){ let vm = this; - //vm.eventListeners(); + vm.eventListeners(); vm.initialiseScientificNameLookup(); vm.loadTaxonomydetails(); } diff --git a/boranga/migrations/0157_merge_20230808_1016.py b/boranga/migrations/0157_merge_20230808_1016.py new file mode 100644 index 000000000..f93cbe2be --- /dev/null +++ b/boranga/migrations/0157_merge_20230808_1016.py @@ -0,0 +1,14 @@ +# Generated by Django 3.2.20 on 2023-08-08 02:16 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('boranga', '0154_speciesconservationattributes_flowering_prd'), + ('boranga', '0156_auto_20230803_1408'), + ] + + operations = [ + ] diff --git a/boranga/migrations/0158_auto_20230808_1029.py b/boranga/migrations/0158_auto_20230808_1029.py new file mode 100644 index 000000000..da859656e --- /dev/null +++ b/boranga/migrations/0158_auto_20230808_1029.py @@ -0,0 +1,42 @@ +# Generated by Django 3.2.20 on 2023-08-08 02:29 + +from django.db import migrations, models +import django.db.models.deletion +import multiselectfield.db.fields + + +class Migration(migrations.Migration): + + dependencies = [ + ('boranga', '0157_merge_20230808_1016'), + ] + + operations = [ + migrations.AlterModelOptions( + name='proposalamendmentreason', + options={'verbose_name': 'Proposal Amendment Reason', 'verbose_name_plural': 'Proposal Amendment Reasons'}, + ), + migrations.RemoveField( + model_name='speciesconservationattributes', + name='flowering_period', + ), + migrations.AddField( + model_name='speciesconservationattributes', + name='flowering_period', + field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='boranga.floweringperiod'), + ), + migrations.AlterField( + model_name='speciesconservationattributes', + name='flowering_prd', + field=multiselectfield.db.fields.MultiSelectField(blank=True, choices=[('january', 'January'), ('february', 'February'), ('march', 'March'), ('april', 'April'), ('may', 'May'), ('june', 'June'), ('july', 'July'), ('august', 'August'), ('september', 'September'), ('october', 'October'), ('november', 'November'), ('december', 'December')], max_length=250, null=True), + ), + migrations.RemoveField( + model_name='speciesconservationattributes', + name='fruiting_period', + ), + migrations.AddField( + model_name='speciesconservationattributes', + name='fruiting_period', + field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='boranga.fruitingperiod'), + ), + ] diff --git a/boranga/migrations/0159_auto_20230808_1042.py b/boranga/migrations/0159_auto_20230808_1042.py new file mode 100644 index 000000000..c5eabd12a --- /dev/null +++ b/boranga/migrations/0159_auto_20230808_1042.py @@ -0,0 +1,28 @@ +# Generated by Django 3.2.20 on 2023-08-08 02:42 + +from django.db import migrations +import multiselectfield.db.fields + + +class Migration(migrations.Migration): + + dependencies = [ + ('boranga', '0158_auto_20230808_1029'), + ] + + operations = [ + migrations.RemoveField( + model_name='speciesconservationattributes', + name='flowering_prd', + ), + migrations.AlterField( + model_name='speciesconservationattributes', + name='flowering_period', + field=multiselectfield.db.fields.MultiSelectField(blank=True, choices=[(1, 'January'), (2, 'February'), (3, 'March'), (4, 'April'), (5, 'May'), (6, 'June'), (7, 'July'), (8, 'August'), (9, 'September'), (10, 'October'), (11, 'November'), (12, 'December')], max_length=250, null=True), + ), + migrations.AlterField( + model_name='speciesconservationattributes', + name='fruiting_period', + field=multiselectfield.db.fields.MultiSelectField(blank=True, choices=[(1, 'January'), (2, 'February'), (3, 'March'), (4, 'April'), (5, 'May'), (6, 'June'), (7, 'July'), (8, 'August'), (9, 'September'), (10, 'October'), (11, 'November'), (12, 'December')], max_length=250, null=True), + ), + ] diff --git a/boranga/migrations/0160_alter_speciesconservationattributes_breeding_period.py b/boranga/migrations/0160_alter_speciesconservationattributes_breeding_period.py new file mode 100644 index 000000000..431242358 --- /dev/null +++ b/boranga/migrations/0160_alter_speciesconservationattributes_breeding_period.py @@ -0,0 +1,19 @@ +# Generated by Django 3.2.20 on 2023-08-08 03:04 + +from django.db import migrations +import multiselectfield.db.fields + + +class Migration(migrations.Migration): + + dependencies = [ + ('boranga', '0159_auto_20230808_1042'), + ] + + operations = [ + migrations.AlterField( + model_name='speciesconservationattributes', + name='breeding_period', + field=multiselectfield.db.fields.MultiSelectField(blank=True, choices=[(1, 'January'), (2, 'February'), (3, 'March'), (4, 'April'), (5, 'May'), (6, 'June'), (7, 'July'), (8, 'August'), (9, 'September'), (10, 'October'), (11, 'November'), (12, 'December')], max_length=250, null=True), + ), + ] diff --git a/boranga/migrations/0161_auto_20230808_1201.py b/boranga/migrations/0161_auto_20230808_1201.py new file mode 100644 index 000000000..eca983cce --- /dev/null +++ b/boranga/migrations/0161_auto_20230808_1201.py @@ -0,0 +1,22 @@ +# Generated by Django 3.2.20 on 2023-08-08 04:01 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('boranga', '0160_alter_speciesconservationattributes_breeding_period'), + ] + + operations = [ + migrations.AlterModelOptions( + name='breedingperiod', + options={}, + ), + migrations.AlterField( + model_name='breedingperiod', + name='period', + field=models.CharField(choices=[('January', 'January'), ('February', 'February'), ('March', 'March'), ('April', 'April'), ('May', 'May'), ('June', 'June'), ('July', 'July'), ('August', 'August'), ('September', 'September'), ('October', 'October'), ('November', 'November'), ('December', 'December')], max_length=200, unique=True), + ), + ]