[go: up one dir, main page]

Page MenuHomePhabricator

Add "Create new item" link to property value drop-down menu (particularly when no item matches) in Wikidata
Open, Needs TriagePublic

Assigned To
None
Authored By
Mvolz
Aug 2 2015, 11:09 AM
Referenced Files
F55071158: Screenshot 2024-06-08 182146.png
Jun 8 2024, 5:21 PM
F55071156: Screenshot 2024-06-08 182034.png
Jun 8 2024, 5:21 PM
Tokens
"Like" token, awarded by Akuckartz."Love" token, awarded by MichaelSchoenitzer."Yellow Medal" token, awarded by Liuxinyu970226."Love" token, awarded by Sjoerddebruin."Party Time" token, awarded by Esc3300."Yellow Medal" token, awarded by Josve05a.

Description

It would be really great in wikidata for there to be a "create new item" link in the dropdown menu for when you want to add an item to a property, but the item does not exist. The current workflow is to try to add an item, see it doesn't exist yet, navigate away from the page, and then create a new item, navigate back to the original page, and then add it.

(Even better would be if it were possible to create an item without leaving the page, i.e. create an item by name and then directly add it from the page, maybe in a pop-up. Then, presumably the user could go on to expand the newly created item.

The tool could even be extended to add citoid support for references by allowing users to add items as references this way, and attempt to use citoid to fill in some of the parameters. (T131661).

This project could start life as an on wiki Gadget and then later be added to the WikibaseRepository extension. )

Event Timeline

Mvolz raised the priority of this task from to Needs Triage.
Mvolz updated the task description. (Show Details)
Mvolz added a project: Wikidata.
Mvolz moved this task to incoming on the Wikidata board.
Mvolz subscribed.

It is duplicate of T51068, but that task was closed as declined a year ago.

I thought it seemed obvious but couldn't find that, thanks. Looks like it
was closed as it should start life as a gadget, but no one ever made one?
Alas.
matej_suchanek added a subscriber: matej_suchanek.
matej_suchanek added a comment.

It is duplicate of https://phabricator.wikimedia.org/T51068, but that task
was closed as declined a year ago.

TASK DETAIL

https://phabricator.wikimedia.org/T107693

EMAIL PREFERENCES

https://phabricator.wikimedia.org/settings/panel/emailpreferences/

To: matej_suchanek
Cc: matej_suchanek, Aklapper, Mvolz, Wikidata-bugs, aude, Malyacko, P.Copp

daniel subscribed.

Setting this to low. I'd personally love to have this feature, but there seems to be surprisingly little demand. And it could easily be implemented as a gadget.

Now that there is a text showing up during no results, it should be much easier to create a gadget. A link to a pre-filled Special:NewItem would do.

Aklapper added a subscriber: Ladsgroup.

@Ladsgroup: If you plan to mentor this in GCi2017, could you edit the task description and explain which exact odebase(s) this task is about? Thanks!

Mvolz renamed this task from Add "Create new item" link to property value drop-down menu (particularly when no item matches) to Add "Create new item" link to property value drop-down menu (particularly when no item matches) in Wikidata.Nov 25 2017, 11:06 PM
Mvolz updated the task description. (Show Details)
Mvolz updated the task description. (Show Details)

@Ladsgroup: If you plan to mentor this in GCi2017, could you edit the task description and explain which exact odebase(s) this task is about? Thanks!

Whoops, I misread that as GSoC and just expanded it to be more GSoC-y. It could *potentially* be a fairly involved project.

But just adding the link would be a great first step - but the discussion seems to be talking about making a gadget. If it's just the link, that seems like something simple that could be added directly to wikibase?

I am not convinced this is a beneficial change which is why I want this to be trialed as a gadget first.

@Ladsgroup: If you plan to mentor this in GCi2017, could you edit the task description and explain which exact odebase(s) this task is about? Thanks!

The codebase about this would be a user script (User:Foo/common.js) and they way to test it, would be to copy paste it in console. Is this enough?

I guess that this gadget will have to override _initMenu function in jquery.wikibase.entityselector.js and replace the null with the open new URL function?

customItems.unshift( new $.ui.ooMenu.CustomItem(
    this.options.messages.notfound,
    function () {
      return self._cache.suggestions && !self._cache.suggestions.length
        && self.element.val().trim() !== '';
    },
    null,
    'ui-entityselector-notfound'
  ) );

But I can't find how to do this with user script. Or is there any other easier method?

You should be able to traverse the DOM with JS to insert it directly into
the menu. Try inspecting the element using your browser's debugger to see
where that would be.

I guess the hard part is when the script should be triggered; maybe on
typing in the box? And check every time to see if the list has no results
and then replace it?

(If nothing I'm typing is making sense please ask for clarification :))

https://www.wikidata.org/wiki/User:Eflyjason/Gadget-CreateNewItem.js

var currentFieldText = "";
$(document).on('input propertychange paste', ".ui-suggester-input", function() {
	currentFieldText = $(this).val();
	//console.log("Entering: "+currentFieldText);
});
$(document).on('DOMSubtreeModified', ".ui-entityselector-list",function(){
	var firstLi = $(this).find("li").first();
	var isNotFound = firstLi.hasClass('ui-entityselector-notfound');
	console.log('Current Text Field content: '+currentFieldText+". Not found: "+isNotFound);
	if(isNotFound){
		var innerA = firstLi.find("a").first();
		innerA.attr("href", "https://www.wikidata.org/wiki/Special:NewItem?label="+currentFieldText).attr("target", "_blank");
	}
});

The basic feature should be working right now :D (though I'm not sure if it's the best approach?)

I will optimize it and make it into a popup later :D

Great so far! Is it possible to use OOjs UI for the popup though? We are slowly transforming our current gadgets to it. The form will automatically look correct as well then.

Nice!

But I'm getting an error when trying to create an item from the pop-up

"[Wiws9wpAME0AABYAle0AAABL] 2017-12-09 18:35:51: Fatal exception of type "Wikimedia\Rdbms\DBQueryError"

Also it would be nice if there was some indication that you can click on the no results found link - like making a "create new item" link and have it be underlined, so people know it's clickable.

I don't want feature creep on this, honestly having the pop-up at all is great (even if it isn't OOUI) - it *is* supposed to be a small task!

https://www.wikidata.org/w/index.php?title=User:Eflyjason/Gadget-CreateNewItem.js&oldid=606566480


Great so far! Is it possible to use OOjs UI for the popup though? We are slowly transforming our current gadgets to it. The form will automatically look correct as well then.

Updated with OOjs UI :D


Also it would be nice if there was some indication that you can click on the no results found link - like making a "create new item" link and have it be underlined, so people know it's clickable.

Added :)


But I'm getting an error when trying to create an item from the pop-up

"[Wiws9wpAME0AABYAle0AAABL] 2017-12-09 18:35:51: Fatal exception of type "Wikimedia\Rdbms\DBQueryError"

That's weird. I tested again and created entity successfully.


There are some problems related performance I think caused by DOMSubtreeModified. It would be nice if there are .on for detecting the list change directly.

"[Wiws9wpAME0AABYAle0AAABL] 2017-12-09 18:35:51: Fatal exception of type "Wikimedia\Rdbms\DBQueryError"

Looks like a temp. problem T182505.

I saw that the script also affects the property input field, I don't think that should be happening.

I saw that the script also affects the property input field, I don't think that should be happening.

Fixed :D

https://www.wikidata.org/w/index.php?title=User:Eflyjason/Gadget-CreateNewItem.js&oldid=606686398

I saw that the script also affects the property input field, I don't think that should be happening.

Fixed :D

https://www.wikidata.org/w/index.php?title=User:Eflyjason/Gadget-CreateNewItem.js&oldid=606686398

Would you like to submit this work for review on the google code-in website? We can't approve it unless that is done :).

Would you like to submit this work for review on the google code-in website? We can't approve it unless that is done :).

Thank you! I've added it to https://www.wikidata.org/wiki/Wikidata:Tools/User_scripts#AddNewItem and also localized the script in Chinese. :D

srishakatux subscribed.

Removing the Possible-Tech-Projects tag as we are planning to kill it soon! This project does not seem to fit in the Outreach-Programs-Projects category in its current state, so I am not adding that tag right now!

It would be great if the script allowed to create a new item even if there are (irrelevant) results.

I tried porting this script to use the new mutation observer but failed.
For some reason after making the replace the entityselector resets and the replacement disappears.

Further complicating matters is that there are multiple entityselector lists hidden in the background and it is impossible to know which one is related to the current textarea.

Further complicating matters is that there can be multiple textareas on the page at the same time and the script has no idea which entityselector corresponds to which textarea.

My conclusion is that this cannot be done well with a user script at this time. If textareas were given an id and the corresponding entityselector list a similar id it would be easier to distinguish. see https://phabricator.wikimedia.org/T290298

See https://www.wikidata.org/wiki/User:So9q/CreateNewEntity.js

I did succeed in getting it usable on lexemes though before the reset bug appeared a while back :)

Lydia_Pintscher raised the priority of this task from Low to Needs Triage.Sep 3 2021, 10:55 AM

I had another go at a userscript for this. See https://www.wikidata.org/wiki/User:Zvpunry/CreateNewItem for instructions how to use it.

Screenshot 2024-06-08 182034.png (219×922 px, 12 KB)

Screenshot 2024-06-08 182146.png (581×586 px, 29 KB)