Skip to content
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

Add an HFOSS filter to the UI #13

Open
bacharakis opened this issue Sep 26, 2018 · 17 comments
Open

Add an HFOSS filter to the UI #13

bacharakis opened this issue Sep 26, 2018 · 17 comments
Assignees
Labels
good first issue Good for newcomers

Comments

@bacharakis
Copy link
Contributor

Add an HFOSS filter on the UI/filters list
screenshot from 2018-09-26 16-36-48

@bacharakis bacharakis added the good first issue Good for newcomers label Sep 26, 2018
@katiehrenchir katiehrenchir self-assigned this Sep 27, 2018
@katiehrenchir
Copy link

@alexdor Hello Alex, we are trying to add an HFOSS BooleanInput to the admin console, and then, if it is selected, we'd like to have a method execute that will add 'HFOSS' to the tags of the project. Can you help us with the syntax for executing a method if the BooleanInput is set to true?

@alexdor
Copy link
Member

alexdor commented Sep 27, 2018

Hello @katiehrenchir in order to implement this functionality 2 tasks need to be completed.
For the frontend a new boolean field should be added on the src/routes/Admin/components/Projects.tsx file

For the backend, the project model needs to be updated to include a boolean field that indicates whether this project is 'HFOSS' or not (with the default value set to false). In order to achieve that a new column needs to be created at the database and the project model needs to be updated with the new field. Once the model is updated the backend will automatically include the new field on every Get, Post and Put request.

Please let me know if you would like more info about any specific part : )

@katiehrenchir
Copy link

Ok! We have added the BooleanInput component to the create and edit sections of src/routes/Admin/components/Projects.tsx
<BooleanInput label="HFOSS?" />

and then we also just added this to the backend's Projects.go file
HFOSS bool json:"HFOSS" db:"HFOSS"

@katiehrenchir
Copy link

Now we would like to have some code that adds 'HFOSS' to the tags of the Project based upon the value of the HFOSS boolean field

@alexdor
Copy link
Member

alexdor commented Sep 27, 2018

you also need to add a new database migration. You need to create a migration similar to this one migrations/20180830162007_AddTagsToRepos.up.fizz but with the column that you want. You can generate a migration file by running this command buffalo db generate fizz add_hfoss_column_to_projects

@katiehrenchir
Copy link

We don't want to create a new column for HFOSS in the database, we just want to add or remove the HFOSS tag from the existing Tags based on the BooleanInput value... can this be accomplished with an "action" instead of a database change?

@alexdor
Copy link
Member

alexdor commented Sep 27, 2018

Unfortunately, this can't be done by a simple action. The reason is that tags are parsed automatically by GitHub, if you add a tag (with the current setup) it will be overwritten when the project is fetched from GitHub.
Another approach (instead of creating a boolean field in the database) is to create a new column of type array (named AdminTags, or something similar) that would store all the extra tags that an admin wants to add to this project.

@katiehrenchir
Copy link

How often is the project "fetched"? Is it every time the page is loaded, or only when the project object is created/edited?

@alexdor
Copy link
Member

alexdor commented Sep 27, 2018 via email

@katiehrenchir
Copy link

Alex, this is our migration
add_column("projects", "HFOSS", "boolean", {"null": true})

and we added this line to the admin Projects file
<BooleanField source="HFOSS" label="HFOSS?" />

Christos said that the environment should automatically do the migration for us? However, the admin console's projects list now says "No results found" so something about this is wrong, I suspect the migration. I think this added HFOSS to the Projects table, right?

@alexdor
Copy link
Member

alexdor commented Sep 27, 2018 via email

@katiehrenchir
Copy link

Alex, here is the output: https://pastebin.com/1eXwtCyK

@alexdor
Copy link
Member

alexdor commented Sep 27, 2018

@katiehrenchir could you upload the source code somewhere as well so I can try to see why is the migration not running? (You could push it to your fork of the repo)

@katiehrenchir
Copy link

Alex, I have pushed the changes to my fork of the backend.

@alexdor
Copy link
Member

alexdor commented Sep 27, 2018

I've left a comment with a possible issue, when you have a look and let me know if it worked : )

@siddhant1
Copy link
Collaborator

@alexdor is this being worked on now?

@alexdor
Copy link
Member

alexdor commented Mar 4, 2019

@siddhant1 no I've left my comments here katiehrenchir/fixme_backend@4fa6636

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

4 participants