Skip to content

Commit

Permalink
Merge branch 'main' into prod/festapp
Browse files Browse the repository at this point in the history
  • Loading branch information
miakh committed Nov 21, 2024
2 parents 9b923bc + eefb48a commit 79ea4d0
Show file tree
Hide file tree
Showing 10 changed files with 36 additions and 26 deletions.
1 change: 1 addition & 0 deletions lib/components/dataGrid/DataGridHelper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ class DataGridHelper
String currentState = rendererContext.cell.value ?? DbOccasions.serviceNone;

return CustomThreeStateCheckbox(
noneStateIcon: Icons.circle_outlined,
paidStateIcon: Icons.flatware,
usedStateIcon: Icons.restaurant_menu,
currentState: currentState,
Expand Down
2 changes: 2 additions & 0 deletions lib/dataModels/OccasionUserModel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ class OccasionUserModel extends IPlutoRowModel {
Tb.occasion_users.data_email: json[Tb.occasion_users.data_email],
Tb.occasion_users.data_name: json[Tb.occasion_users.data_name],
Tb.occasion_users.data_surname: json[Tb.occasion_users.data_surname],
Tb.occasion_users.data_sex: json[Tb.occasion_users.data_sex],
Tb.occasion_users.data_phone: json[Tb.occasion_users.data_phone],
Tb.occasion_users.data_text1: json[Tb.occasion_users.data_text1],
Tb.occasion_users.data_text2: json[Tb.occasion_users.data_text2],
Expand Down Expand Up @@ -263,6 +264,7 @@ class OccasionUserModel extends IPlutoRowModel {
return compareField(iu, Tb.occasion_users.data_email, Tb.occasion_users.data_email)
&& compareField(iu, Tb.occasion_users.data_name, Tb.occasion_users.data_name)
&& compareField(iu, Tb.occasion_users.data_surname, Tb.occasion_users.data_surname)
&& compareField(iu, Tb.occasion_users.data_sex, Tb.occasion_users.data_sex)
&& iu[Tb.user_info.role] == role
&& compareField(iu, Tb.occasion_users.data_phone, Tb.occasion_users.data_phone)
&& compareField(iu, Tb.occasion_users.data_text1, Tb.occasion_users.data_text1)
Expand Down
26 changes: 10 additions & 16 deletions lib/dataServices/DbGroups.dart
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,7 @@ class DbGroups {
}

static updateUserGroupInfo(UserGroupInfoModel model) async {
if(!(RightsService.isEditor() || model.leader!.id == AuthService.currentUserId()))
{
if(!(RightsService.isEditor() || model.leader!.id == AuthService.currentUserId())) {
throw Exception("Must be leader or admin to change the group.");
}

Expand All @@ -79,29 +78,25 @@ class DbGroups {
Tb.user_group_info.leader: model.leader?.id,
};

if(model.type != null)
{
if(model.type != null) {
upsertObj.addAll({Tb.user_group_info.type: model.type});
}
if(model.description != null)
{
if(model.description != null) {
upsertObj.addAll({Tb.user_group_info.description: model.description});
}
if(model.place != null)
{
if(model.place != null) {
model.place = await DbPlaces.updatePlace(model.place!);
upsertObj.addAll({Tb.user_group_info.place: model.place!.id.toString()});
}
dynamic eventData;
if(model.id!=null) {
upsertObj.addAll({Tb.user_group_info.id: model.id.toString()});
eventData = await _supabase.from(Tb.user_group_info.table).upsert(upsertObj).eq(Tb.user_group_info.id, model.id!).select().single();
}
else
{
eventData = await _supabase.from(Tb.user_group_info.table).update(upsertObj).eq(Tb.user_group_info.id, model.id!).select().single();
} else {
upsertObj.addAll({Tb.user_group_info.occasion: RightsService.currentOccasion!});
eventData = await _supabase.from(Tb.user_group_info.table).insert(upsertObj).select().single();
}

var updated = UserGroupInfoModel.fromJson(eventData);
await updateUserGroupParticipants(updated, model.participants!);
}
Expand All @@ -112,8 +107,7 @@ class DbGroups {
.delete()
.eq(Tb.user_groups.group, group.id!);

for(var p in participants)
{
for(var p in participants) {
await _supabase
.from(Tb.user_groups.table)
.insert({
Expand All @@ -132,8 +126,8 @@ class DbGroups {
.from(Tb.user_group_info.table)
.delete()
.eq(Tb.user_group_info.id, model.id!);
if(model.place!=null)
{

if(model.place!=null) {
await _supabase
.from(Tb.places.table)
.delete()
Expand Down
2 changes: 1 addition & 1 deletion lib/dataServices/RightsService.dart
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class RightsService{
}

static bool canUpdateUsers() {
return isEditor() || isAdmin();
return isManager() || isAdmin();
}

static bool canSignInOutUsersFromEvents() {
Expand Down
12 changes: 11 additions & 1 deletion lib/pages/AdministrationOccasion/ColumnHelper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class ColumnHelper {
static const String ROLE = "role";
static const String TEXT1 = "text1";
static const String TEXT2 = "text2";
static const String TEXT3 = "text3";
static const String NOTE = "note";
static const String DIET = "diet";
static const String ADMINISTRATOR = "administrator";
Expand Down Expand Up @@ -125,6 +126,15 @@ class ColumnHelper {
width: 100,
),
],
TEXT3: [
PlutoColumn(
title: "Číslo týmu (hra)",
enableEditingMode: RightsService.canUpdateUsers(),
field: Tb.occasion_users.data_text3,
type: PlutoColumnType.text(),
width: 100,
),
],
NOTE: [
PlutoColumn(
title: "Note".tr(),
Expand Down Expand Up @@ -165,7 +175,7 @@ class ColumnHelper {
field: DbOccasions.serviceTypeAccommodation,
type: PlutoColumnType.select(select),
applyFormatterInEditing: true,
enableEditingMode: true,
enableEditingMode: RightsService.canUpdateUsers(),
width: 100
)];
},
Expand Down
6 changes: 4 additions & 2 deletions lib/pages/AdministrationOccasion/ServiceTab.dart
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,13 @@ class _ServiceTabState extends State<ServiceTab> {
DataGridAction(
name: "Accommodation settings".tr(),
action: (SingleTableDataGrid p0, [_]) =>
_accommodationDefinition(p0)),
_accommodationDefinition(p0),
isEnabled: RightsService.isManager),
DataGridAction(
name: "Food settings".tr(),
action: (SingleTableDataGrid p0, [_]) =>
_foodDefinition(p0)),
_foodDefinition(p0),
isEnabled: RightsService.isManager),
],
columns: ColumnHelper.generateColumns(columnIdentifiers, data: {
ColumnHelper.FOOD: allFood,
Expand Down
6 changes: 3 additions & 3 deletions lib/pages/AdministrationOccasion/UsersTab.dart
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,10 @@ class _UsersTabState extends State<UsersTab> {
actionsExtended: DataGridActionsController(
areAllActionsEnabled: RightsService.canUpdateUsers),
headerChildren: [
DataGridAction(name: "Import".tr(), action: (SingleTableDataGrid p0, [_]) => _import(p0)),
DataGridAction(name: "Import".tr(), action: (SingleTableDataGrid p0, [_]) => _import(p0), isEnabled: RightsService.canUpdateUsers),
DataGridAction(name: "Add existing".tr(), action: (SingleTableDataGrid p0, [_]) => _addExisting(p0)),
DataGridAction(name: "Invite".tr(), action: (SingleTableDataGrid p0, [_]) => _invite(p0)),
DataGridAction(name: "Change password".tr(), action: (SingleTableDataGrid p0, [_]) => _setPassword(p0)),
DataGridAction(name: "Invite".tr(), action: (SingleTableDataGrid p0, [_]) => _invite(p0), isEnabled: RightsService.canUpdateUsers),
DataGridAction(name: "Change password".tr(), action: (SingleTableDataGrid p0, [_]) => _setPassword(p0), isEnabled: RightsService.canUpdateUsers),
DataGridAction(name: "Add to group".tr(), action: (SingleTableDataGrid p0, [_]) => _addToGroup(p0)),
],
columns: ColumnHelper.generateColumns(columnIdentifiers),
Expand Down
3 changes: 2 additions & 1 deletion lib/services/ImportHelper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import 'package:intl/intl.dart';
class ImportHelper {
static Map<String, String> get migrateColumns => {
Tb.occasion_users.data_email: "E-mailová adresa",
Tb.occasion_users.data_sex: "Jsi:",
Tb.occasion_users.data_name: "Jméno:",
Tb.occasion_users.data_surname: "Příjmení:",
Tb.occasion_users.services_accommodation: "Ubytování:",
Expand Down Expand Up @@ -68,7 +69,7 @@ class ImportHelper {
break;
}
trimmedString =
trimmedString.toLowerCase().startsWith("m") ? "male" : "female";
(trimmedString.toLowerCase().startsWith("m") || trimmedString.toLowerCase().startsWith("k")) ? "male" : "female";
} else if (entry.key == Tb.occasion_users.data_birthDate) {
if (trimmedString.isEmpty) {
continue;
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
# In Windows, build-name is used as the major, minor, and patch parts
# of the product and file versions while build-number is used as the build suffix.
version: 0.10.13+98
version: 0.10.14+99

environment:
sdk: '>=2.19.5 <3.22.1'
Expand Down
2 changes: 1 addition & 1 deletion scripts/database/users/set_user_password.sql
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ AS $$
declare
encrypted_pw text;
BEGIN
IF (SELECT get_is_manager_on_occasion(oc)) <> TRUE OR (SELECT get_is_admin_on_occasion(oc)) <> TRUE THEN
IF (SELECT get_is_manager_on_occasion(oc)) <> TRUE AND (SELECT get_is_admin_on_occasion(oc)) <> TRUE THEN
RETURN NULL;
END IF;

Expand Down

0 comments on commit 79ea4d0

Please sign in to comment.