OH-SHOWN / ohshown-backend

OH!SHOWN 野生動物出沒痕跡通報系統
http://ohshown.site
MIT License
2 stars 8 forks source link

[Feature request] refactoring the the string element of `Ohshown event type` and aligned it with the frontend #15

Closed tai271828 closed 2 years ago

tai271828 commented 2 years ago

The current string element of Ohshown event type looks like this:

Selection_577

and it is not aligned with the string element in the frontend draw-down list: Selection_578

Selection_579

We have to aligned them.

EagleC0318 commented 2 years ago

Is the FE dropped-down list defined in somewhere?

tai271828 commented 2 years ago
$ grep 人熊衝突 -r ./src/
./src/types.ts:  { value: '3', text: '人熊衝突現場痕跡 - 雞舍' },
./src/types.ts:  { value: '4', text: '人熊衝突現場痕跡 - 果園' },
./src/types.ts:  { value: '5', text: '人熊衝突現場痕跡 - 其他' },

By the way for backend

$ grep 焊接 -r ./
./api/migrations/0008_change_factory_status.py:            field=models.CharField(blank=True, choices=[('2-1', '沖床
、銑床、車床、鏜孔'), ('2-2', '焊接、鑄造、熱處理'), ('2-3', '金屬表面處理、噴漆'), ('3', '塑膠加工、射出'), ('4', '
橡膠加工'), ('5', '非金屬礦物(石材)'), ('6', '食品'), ('7', '皮革'), ('8', '紡織'), ('9', '其他')], max_length=3, null=True),
./api/migrations/0001_initial.py:                ('factory_type', models.CharField(choices=[('1', '金屬'), ('2-1', '
沖床、銑床、車床、鏜孔'), ('2-2', '焊接、鑄造、熱處理'), ('2-3', '金屬表面處理、噴漆'), ('3', '塑膠加工、射出'), ('4', '橡膠加工'), ('5', '非金屬礦物(石材)'), ('6', '食品'), ('7', '皮革'), ('8', '紡織'), ('9', '其他')], default='9', max_length=3)),
./api/models/factory.py:        ("2-2", "焊接、鑄造、熱處理"),
tai271828 commented 2 years ago
$ grep 人熊衝突 -r ./src/
./src/types.ts:  { value: '3', text: '人熊衝突現場痕跡 - 雞舍' },
./src/types.ts:  { value: '4', text: '人熊衝突現場痕跡 - 果園' },
./src/types.ts:  { value: '5', text: '人熊衝突現場痕跡 - 其他' },

This conversation may be useful as well https://github.com/tai271828/disfactory-frontend/pull/14/files#r760667936 .

The string is a part of REPORT_TYPE, which will be an attribute of formState. The data structure of fromState should be what you want to know. Check the link of the conversation for more details : )

By the way for backend

$ grep 焊接 -r ./
./api/migrations/0008_change_factory_status.py:            field=models.CharField(blank=True, choices=[('2-1', '沖床
、銑床、車床、鏜孔'), ('2-2', '焊接、鑄造、熱處理'), ('2-3', '金屬表面處理、噴漆'), ('3', '塑膠加工、射出'), ('4', '
橡膠加工'), ('5', '非金屬礦物(石材)'), ('6', '食品'), ('7', '皮革'), ('8', '紡織'), ('9', '其他')], max_length=3, null=True),
./api/migrations/0001_initial.py:                ('factory_type', models.CharField(choices=[('1', '金屬'), ('2-1', '
沖床、銑床、車床、鏜孔'), ('2-2', '焊接、鑄造、熱處理'), ('2-3', '金屬表面處理、噴漆'), ('3', '塑膠加工、射出'), ('4', '橡膠加工'), ('5', '非金屬礦物(石材)'), ('6', '食品'), ('7', '皮革'), ('8', '紡織'), ('9', '其他')], default='9', max_length=3)),
./api/models/factory.py:        ("2-2", "焊接、鑄造、熱處理"),
EagleC0318 commented 2 years ago

Thanks @tai271828 ! Maybe we could define the resource in the BE, and the BE can provide an API endpoint for the FE to get the resource list.

tai271828 commented 2 years ago

Per discussion today in the regular meetup: Eagle will try to modularize the drop-down list object and evaluate if it is small enough for refactoring. If it is too big for alpha version refactoring, we will think about the other approach.

tai271828 commented 2 years ago

Aligned with @Neilxx and @diaoga today. Verified with the development site.