Skip to content

Commit

Permalink
feat(#122): introducing additional fields
Browse files Browse the repository at this point in the history
  • Loading branch information
sgrimault committed Jun 1, 2023
1 parent 051c2c6 commit 0d94f0b
Show file tree
Hide file tree
Showing 41 changed files with 1,811 additions and 165 deletions.
Original file line number Diff line number Diff line change
@@ -1,22 +1,32 @@
package fr.geonature.occtax.features.nomenclature

import android.content.Context
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.android.qualifiers.ApplicationContext
import dagger.hilt.components.SingletonComponent
import fr.geonature.commons.data.GeoNatureModuleName
import fr.geonature.commons.data.LocalDatabase
import fr.geonature.commons.data.dao.NomenclatureDao
import fr.geonature.commons.data.dao.NomenclatureTypeDao
import fr.geonature.commons.features.nomenclature.data.AdditionalFieldLocalDataSourceImpl
import fr.geonature.commons.features.nomenclature.data.IAdditionalFieldLocalDataSource
import fr.geonature.commons.features.nomenclature.data.INomenclatureLocalDataSource
import fr.geonature.commons.features.nomenclature.data.NomenclatureLocalDataSourceImpl
import fr.geonature.datasync.api.IGeoNatureAPIClient
import fr.geonature.datasync.sync.repository.ISynchronizeAdditionalDataRepository
import fr.geonature.occtax.features.nomenclature.data.INomenclatureSettingsLocalDataSource
import fr.geonature.occtax.features.nomenclature.data.IPropertyValueLocalDataSource
import fr.geonature.occtax.features.nomenclature.data.InMemoryPropertyValueLocalDataSourceImpl
import fr.geonature.occtax.features.nomenclature.data.NomenclatureSettingsLocalDataSourceImpl
import fr.geonature.occtax.features.nomenclature.repository.AdditionalFieldRepositoryImpl
import fr.geonature.occtax.features.nomenclature.repository.DefaultPropertyValueRepositoryImpl
import fr.geonature.occtax.features.nomenclature.repository.IAdditionalFieldRepository
import fr.geonature.occtax.features.nomenclature.repository.IDefaultPropertyValueRepository
import fr.geonature.occtax.features.nomenclature.repository.INomenclatureRepository
import fr.geonature.occtax.features.nomenclature.repository.NomenclatureRepositoryImpl
import fr.geonature.occtax.features.nomenclature.repository.SynchronizeAdditionalFieldRepositoryImpl
import javax.inject.Singleton

/**
Expand Down Expand Up @@ -54,6 +64,18 @@ object NomenclatureModule {
return InMemoryPropertyValueLocalDataSourceImpl()
}

@Singleton
@Provides
fun provideAdditionalFieldDataSource(
@GeoNatureModuleName moduleName: String,
database: LocalDatabase,
): IAdditionalFieldLocalDataSource {
return AdditionalFieldLocalDataSourceImpl(
moduleName,
database
)
}

@Singleton
@Provides
fun provideNomenclatureRepository(
Expand All @@ -77,4 +99,28 @@ object NomenclatureModule {
nomenclatureLocalDataSource
)
}

@Singleton
@Provides
fun provideAdditionalFieldRepository(
additionalFieldLocalDataSource: IAdditionalFieldLocalDataSource
): IAdditionalFieldRepository {
return AdditionalFieldRepositoryImpl(additionalFieldLocalDataSource)
}

@Singleton
@Provides
fun provideSynchronizeAdditionalFieldRepository(
@ApplicationContext appContext: Context,
@GeoNatureModuleName moduleName: String,
additionalFieldLocalDataSource: IAdditionalFieldLocalDataSource,
geoNatureAPIClient: IGeoNatureAPIClient,
): ISynchronizeAdditionalDataRepository {
return SynchronizeAdditionalFieldRepositoryImpl(
appContext,
moduleName,
additionalFieldLocalDataSource,
geoNatureAPIClient
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package fr.geonature.occtax.features.nomenclature.domain

/**
* _Occtax_ additional field types.
*
* @author S. Grimault
*/
enum class AdditionalFieldType(val type: String) {

/**
* Default type.
*/
DEFAULT("OCCTAX_RELEVE"),

/**
* Additional field type used for main information.
*/
INFORMATION("OCCTAX_OCCURENCE"),

/**
* Additional field type used for describing counting.
*/
COUNTING("OCCTAX_DENOMBREMENT")
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,18 @@ data class EditableNomenclatureType(
val viewType: ViewType,
val visible: Boolean = true,
val default: Boolean = true,
val additionalField: Boolean = false,

/**
* Nomenclature type's label.
*/
val label: String? = null,

/**
* Available values for this property.
*/
val values: List<PropertyValue> = emptyList(),

/**
* The current value for this nomenclature type.
*/
Expand Down Expand Up @@ -62,11 +68,31 @@ data class EditableNomenclatureType(
*/
NONE,

/**
* As list of checkboxes.
*/
CHECKBOX,

/**
* As dropdown menu items.
*/
NOMENCLATURE_TYPE,

/**
* As radio group.
*/
RADIO,

/**
* As a single select.
*/
SELECT_SIMPLE,

/**
* As multiselect.
*/
SELECT_MULTIPLE,

/**
* As a simple text field.
*/
Expand All @@ -77,6 +103,11 @@ data class EditableNomenclatureType(
*/
TEXT_MULTIPLE,

/**
* As number text field.
*/
NUMBER,

/**
* As a bounded numerical value.
*/
Expand Down

This file was deleted.

Loading

0 comments on commit 0d94f0b

Please sign in to comment.