-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Generalize form structure for permission requests #315
base: master
Are you sure you want to change the base?
Conversation
* reduce logic at ui level * add 'accepted' and 'processedBy' fields for requests * refactor and format some code for more clarity
…into admin_pannel
* change date place to bottom left corner * change 'deny' bottom colors * add test for admin page * reload only one card instead of all
# Conflicts: # pubspec.yaml
* sort request descending by date * update pubspec.yaml
* update admin panel integration test * resolve warnings
* delete unnecessary mocks * fix Admin Page test
* add test for Admin Panel button * fix typos * reduce duplicated code
# Conflicts: # CONTRIBUTING.md # firestore.indexes.json # firestore.rules
…_forms # Conflicts: # firestore.rules # lib/generated/l10n.dart # lib/main.dart # lib/pages/settings/model/request.dart # lib/pages/settings/service/admin_provider.dart # lib/pages/settings/service/request_provider.dart # lib/pages/settings/view/request_card.dart # pubspec.yaml # test/integration_test.dart # test/settings_test.dart
# Conflicts: # lib/main.dart # lib/pages/settings/view/request_card.dart # test/settings_test.dart
Fix test errors
For more info on versioning, check out our PR guidelines. Generated by 🚫 Danger |
…ions Fix app feedback strings
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a good start, but we can make some improvements.
@@ -126,7 +126,7 @@ service cloud.firestore { | |||
match /forms/{form=**} { | |||
allow read: if true; | |||
allow create: if isAuthenticated(); | |||
allow update: if isAdmin(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we at least have something like isAdmin() || isOwner()? Rather than let any authenticated user edit any document.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All requests are in the same document so everyone should be able to update, to create requests in the first place. A more thorough check is rather complicated.
lib/l10n/intl_ro.arb
Outdated
@@ -303,8 +303,9 @@ | |||
"messageAlreadySeeingCurrentWeek": "Ești deja la săptămâna curentă!", | |||
"messageAnotherQuestion": "Ai altă întrebare?", | |||
"messageTalkToChatbot": "Vorbește cu Polly!", | |||
"messageReportSent": "Reposrt sent successfully.", | |||
"messageReportNotSent": "Reposrt could not be sent.", | |||
"messageReportSent": "Răspuns trimis cu succes.", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch, I actually asked Alex to fix this (#316) so you'll have to resolve some conflicts when you update your branch.
final String questionNumber; | ||
|
||
Map<String, dynamic> toData() { | ||
return {}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't leave this empty; even if we're not using it, it's a good idea to have a stub to fall back to when inheriting (e.g. if we forget to override). It should be a map with the answer & number.
@@ -82,14 +78,14 @@ class FeedbackProvider with ChangeNotifier { | |||
} | |||
} | |||
|
|||
Future<Map<String, FeedbackQuestion>> fetchQuestions() async { | |||
Future<Map<String, FormQuestion>> fetchQuestions(String document) async { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
WDYT about making this public, and adding two helper methods like fetchFeedbackQuestions and fetchPermissionRequestQuestions? And similar to other functions that take the document name.
The reason this would be useful is to not require the UI part to know anything about the database structure. We can just have string constants in this file with the names of the documents and use them directly, so if we at some point rename these documents we only need to change them in one place.
@@ -239,4 +237,47 @@ class FeedbackProvider with ChangeNotifier { | |||
return null; | |||
} | |||
} | |||
|
|||
bool userAlreadyRequestedCache; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe move to the top of the class for consistency with other providers
'done': true, | ||
'accepted': accepted | ||
await _db.collection('forms').doc('permission_request_answers').update({ | ||
'$requestId.processedBy': _authProvider.uid, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Didn't know this syntax is a thing, this is pretty cool!
@@ -45,7 +50,7 @@ class _RequestPermissionsPageState extends State<RequestPermissionsPage> { | |||
color: Theme.of(context).accentColor, | |||
width: 130, | |||
onTap: () async { | |||
Navigator.of(context).pop(); | |||
await _sendRequest(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: This actually doesn't only send the request, but also pops the page. It would be a bit cleaner if you made _sendRequest return a bool (true if success), and then do:
final res = await _sendRequest();
if (!res) {
AppToast...
} else {
AppToast...
Navigator.pop...
}
_fetchUser(); | ||
} | ||
|
||
Future<Map<String, dynamic>> fetchFeedbackQuestions() async { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You forgot to change the name
.fetchQuestions('permission_request_questions') | ||
.then((questions) => setState(() => requestQuestions = questions)); | ||
for (int i = 0; i <= requestQuestions.length; i++) { | ||
answerValues.insert(i, { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand what this does
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This initializes this 'andswerValues' field, which is specific to questions that require a rating. We probably won't use this type of question here though, I will delete this.
@override | ||
Widget build(BuildContext context) { | ||
final requestProvider = Provider.of<RequestProvider>(context); | ||
final requestProvider = Provider.of<FeedbackProvider>(context); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the same code as on the feedback page, no? Why not make a reusable widget like FeedbackPage
now that we have common logic?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It isn't really the same from what I can see. So I think it is better to keep them separated.
# Conflicts: # lib/generated/intl/messages_ro.dart # lib/l10n/intl_ro.arb
Bring the permission request form to the same structure as the class feedback form.
Additional changes: