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 #381 Add hash ids instead of actual ID for model routes [WIP] #777

Merged
merged 122 commits into from
Apr 8, 2018

Conversation

turtles2
Copy link

@turtles2 turtles2 commented Jan 8, 2018

This will close #381 . Its current state its a proof of concept it needs the following things which I will work on.

  • Extend to all Models
  • Add Tests for added functions
  • Modify Tests to Work with new URL structure
  • Allow both old and new URLs to work
  • Add HashIDs to URLs that don't use binding (Add ones from review)

turtles2 and others added 16 commits December 25, 2017 19:27
Change to git clone URL as the git@ will not work without a granted private key.
…icahq#731)

When the current day of the month is greater than the number of days in
the month, the date class was rolling forward to March.
…ahq#735)

This will allow a user to search there contacts by there contact information. It is done by entering the field they are searching by followed by a : then the search term. For example to find a contact with the email [email protected] you would enter email:[email protected]. 

Fixes monicahq#729
Revert "Fix URL::forceSchema to forceScheme (monicahq#730)" (monicahq#744)

use Vinkla\Hashids\Facades\Hashids;

class ID_hasher
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MINOR Rename class "ID_hasher" to match the regular expression ^[A-Z][a-zA-Z0-9]*$. rule

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The name ID_hasher is not PSR1 compliant.

Please change it everywhere with idHasher.

@djaiss
Copy link
Member

djaiss commented Jan 8, 2018

@turtles2 instead of writing Add #381 in the title, could you write a description of what the PR does? It'll be easier. Thanks! And great for the feature you are trying to implement!

@turtles2 turtles2 changed the title Add #381 [WIP] Add #381 Add hash ids instead of actual ID for contacts [WIP] Jan 8, 2018
@turtles2 turtles2 changed the title Add #381 Add hash ids instead of actual ID for contacts [WIP] Add #381 Add hash ids instead of actual ID for model routes [WIP] Jan 8, 2018
@turtles2
Copy link
Author

@djaiss I am unsure on the best way to handle the existing tests. Many of them right now (18) use the model ID in there URL structure that will continue to work. But do we want to change them to use the hashid instead? At first I was thinking that we do but now I think it would be best to leave them as is and only test hashid for the sake of testing hashids.

@asbiin asbiin temporarily deployed to monica-team-pr-777 April 2, 2018 01:36 Inactive
@asbiin asbiin temporarily deployed to monica-team-pr-777 April 2, 2018 02:14 Inactive
@turtles2
Copy link
Author

turtles2 commented Apr 2, 2018

@djaiss I have added the hashIDs to the new relationships but I am getting an error "global_relationship_form_new_contact is not defined" on the editing page. I not sure why I am getting this. Besides this error it is ready for merging.

@djaiss
Copy link
Member

djaiss commented Apr 2, 2018

@turtles2 yes, this error is due to this variable missing in app.js.

To fix it, until a proper fix arrives, you can do this at the bottom of app.js:

loadLanguageAsync(window.Laravel.locale, true).then((lang) => {

    // the Vue appplication
    me.app = new Vue({
      i18n,
      data: {
        activities_description_show: false,
        reminders_frequency: 'once',
        accept_invite_user: false,
        date_met_the_contact: 'known',
        global_relationship_form_new_contact: true,   -----------------HERE
      },
      methods: {
      },
      mounted: function() {

        // required modules
        require('./tags');
        require('./search');
        require('./contacts');

      }
    }).$mount('#app');

    return app;
});

and recompile the assets (npm run prod) and it should work.

@@ -46,7 +46,7 @@
@endif
</div>
<div class="table-cell list-actions">
<a href="{{ route('people.debt.edit', ['people' => $contact->id, 'debtId' => $debt->id]) }}">
<a href="{{ route('people.debt.edit', [$contact, $debt]) }}">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not keep the named attributes here ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@asbiin I would have to test it to be sure but it's one of two reasons. Either there was some quirk in laravels route binding that required it, or I got carried away with find and replace. Looking at I would lean towards the first one.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@turtles2 indeed ! The previous version was obviously buggy. Thanks !

@asbiin asbiin temporarily deployed to monica-team-pr-777 April 4, 2018 17:59 Inactive
@asbiin
Copy link
Member

asbiin commented Apr 4, 2018

We have just switched to Laravel 5.6, so I've updated vinkla/hashids dependency to '^5.0'


public function decodeId($hash)
{
if (str_contains($hash, $this->prefix)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it not be better to call starts_with ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@asbiin Yes it would be. I was not aware of that function.

@asbiin asbiin temporarily deployed to monica-team-pr-777 April 5, 2018 13:46 Inactive
@asbiin asbiin temporarily deployed to monica-team-pr-777 April 7, 2018 08:32 Inactive
@turtles2
Copy link
Author

turtles2 commented Apr 7, 2018 via email

@asbiin
Copy link
Member

asbiin commented Apr 7, 2018

@turtles2 It was related to another issue, fixed in #1114

@djaiss
Copy link
Member

djaiss commented Apr 8, 2018

@turtles2 thanks so much for your patience with this PR. I'm sorry it took so long to merge it.

This is an awesome work.

@turtles2
Copy link
Author

turtles2 commented Apr 8, 2018 via email

@djaiss djaiss merged commit 3ba96cf into monicahq:master Apr 8, 2018
@turtles2 turtles2 deleted the 381 branch April 9, 2018 02:21
@github-actions
Copy link

This pull request has been automatically locked since there
has not been any recent activity after it was closed.
Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 11, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add hash ids instead of actual ID for contacts
6 participants