Page 1 of 1

Change All fields to Read only

Posted: 2018-12-18 09:56
by bescott53
Hi everyone, i want to change all fields to read only, after a field is set to complete. I tried updating the membership_userrecords but this will not work for me. is there another way to complete this?

Re: Change All fields to Read only

Posted: 2018-12-18 12:09
by sjohn
If you ( in admin area ) set the acces to the table to : create new records=allowed edit records=not allowed, then the user can create a new record. The user can also fill in all the fields, and save the record.
But the user is not allowed to edit any of the fields after that.

Another group could have access to edit the data, but not create new records.

This will be a kind of read only, but with the possibility for a user to fill in data.
Was it something like this you meant?

Re: Change All fields to Read only

Posted: 2018-12-18 12:17
by sjohn
Just to be sure : What I describe requires no hooks or coding. It is just about setting the credentials for a table in the admin-area for a group.

Re: Change All fields to Read only

Posted: 2018-12-18 13:06
by bescott53
thanks sjohn, i had run through this but the way i have set up (I have a supervisor who can see the group) who authorises, doing it your way is not possible as supervisor would still need to view but can only be in 1 group and not more than 1 group.

Re: Change All fields to Read only

Posted: 2018-12-18 16:37
by sjohn
Is it not possible to make a supervisor-group, that has the credentials needed for supervisors?
Or - let the supervisor login as supervisor when he should be supervisor, and log in as "normal" user when/if he should be a normal use?

I am just guessing - to suggest a proper solution, requires that one understand what it is all about - and I think I know too little of the structure in your project, to be of any help. Collecting information, and afterwards specifying solutions ready to code has been my job for many years - but I am not a coder. You could say I am an architect - not a craftsman.

Re: Change All fields to Read only

Posted: 2018-12-18 23:01
by Alisson
Not sure if this will work for you. But I've made this work using CSS.
I've added this to the bootstrap.css

Code: Select all

.completed {
  cursor: not-allowed;
  pointer-events: none;
  cursor: default;
  }
  
And this to the tablename.php in the hooks folder

Code: Select all

<script>
\$j(function(){
	\$j('td.tablename-status').each(function(){ 
		if(\$j(this).text() == 'Completed'){\$j(this).parent().addClass('completed');}
         })
});
</script>
Is not the perfect solution because if you type the Id of the record in the address bar you can still view it, but this will prevent the row to be clicked.

Re: Change All fields to Read only

Posted: 2018-12-20 12:45
by bescott53
thanks Alisson, this might work will give it a go