These are chat archives for canjs/canjs

7th
Nov 2017
Nico R.
@nriesco
Nov 07 2017 01:50
@eben-roux try <can-import from="bootstrap/dist/js/bootstrap.js" />
that should work if you installed bootstrap (npm install bootstrap —save)
is that your question?
as for the tether error, maybe you are adding a / at the beginning
or not importing it but requesting it via http
Eben
@eben-roux
Nov 07 2017 07:25
I don't use yarn... but I'll have a look
I really don't get enough time time to spend on my canjs stuff :( --- hopefully I'll have some time in December
Eben
@eben-roux
Nov 07 2017 11:49
@nriesco when would one use can-import and when would one import from, say, the app.js file?
any reason to use the one over the other?
Nico R.
@nriesco
Nov 07 2017 13:44
The example I wrote was to use in a stache file
You don’t need bootstrap anywhere else I guess
Chasen Le Hara
@chasenlehara
Nov 07 2017 18:22
@eben-roux I personally like to use can-import when I really only need something because it’s used in the template (keeps the import closer to the code where it’s used)
…and if you’re using something in your JS, then importing there
Hey @/all, our community survey ends today, if you didn’t receive it in your email you can go directly here to take it: https://www.surveymonkey.com/r/donejs-survey-2
We talked about all the proposals on a live stream last week: https://youtu.be/ieZJrPwSZYQ?t=9m18s
There are timestamps in the video description for when we talked about each item :)
Justin Meyer
@justinbmeyer
Nov 07 2017 21:31
is it possible to search gitter?
Chasen Le Hara
@chasenlehara
Nov 07 2017 21:37
Yeah, in the far left sidebar of the UI you should see a search magnifying glass
Julian
@pYr0x
Nov 07 2017 22:31
hey guys
i have no glue why my can-connection is not working
if have that connection
import DefineMap from "can-define/map/";
import DefineList from "can-define/list/";
import set from "can-set";
import baseMap from "can-connect/can/base-map/";
import superMap from "can-connect/can/super-map/";

const EntnahmestelleDetail = DefineMap.extend({
  seal: false
}, {
  "wwentnahmestelle_id": "any"
});

EntnahmestelleDetail.List = DefineList.extend({
  "#": EntnahmestelleDetail
});

const algebra = new set.Algebra(
  set.props.id("wwentnahmestelle_id")
);


EntnahmestelleDetail.connection = baseMap({
  Map: EntnahmestelleDetail,
  List: EntnahmestelleDetail.List,
  name: "EntnahmestelleDetail",
  algebra,
  // url: window.Config.baseUrl + "/api/entnahmestelle",
  url: {
    getListData: "GET /todos",
    getData: "GET /todos/{id}",
    createData: "POST /todos",
    updateData: "PUT /todos/{id}",
    destroyData: "DELETE /todos/{id}"
  }
});

export default EntnahmestelleDetail;
and call the connection
EntnahmestelleDetail.get({"entnahmestelle_id": newVal}).then((resp) => {
          console.log(resp);
        });`
but instead of going against /todo.... the request is going against http://localhost/triwala/staging/abgeschlossene-touren/import/liegenschaft/triwala-tour/100000/tour-tag-station/1?entnahmestelle_id=5
with entnahmestelle_id as a query param
so what is wrong?
Mohamed Cherif Bouchelaghem
@cherifGsoul
Nov 07 2017 22:35
Hey @pYr0x
Julian
@pYr0x
Nov 07 2017 22:35
hey cherif
Mohamed Cherif Bouchelaghem
@cherifGsoul
Nov 07 2017 22:35
can you check your cache and localstorage maybe is a cache issue
Julian
@pYr0x
Nov 07 2017 22:36
i was using baseMap i though this was without cache
but i will check
Mohamed Cherif Bouchelaghem
@cherifGsoul
Nov 07 2017 22:36
I think it has!
Julian
@pYr0x
Nov 07 2017 22:37
no nothing in it
Mohamed Cherif Bouchelaghem
@cherifGsoul
Nov 07 2017 22:40
what is your base url? is it localhost/ ....
Julian
@pYr0x
Nov 07 2017 22:40
?
url: {
    getListData: "GET /todos",
    getData: "GET /todos/{id}",
    createData: "POST /todos",
    updateData: "PUT /todos/{id}",
    destroyData: "DELETE /todos/{id}"
  }
the request should go to localhost/todos
Mohamed Cherif Bouchelaghem
@cherifGsoul
Nov 07 2017 22:41
yes
Julian
@pYr0x
Nov 07 2017 22:43
but it doesnt
Mohamed Cherif Bouchelaghem
@cherifGsoul
Nov 07 2017 22:44
can you make it in a virtual host instead of localhost?
Julian
@pYr0x
Nov 07 2017 22:45
what makes the difference?
Mohamed Cherif Bouchelaghem
@cherifGsoul
Nov 07 2017 22:45
/todos it will look for the base url
Julian
@pYr0x
Nov 07 2017 22:46
yes
but the request goes to http://localhost/triwala/staging/abgeschlossene-touren/import/liegenschaft/triwala-tour/100000/tour-tag-station/1?entnahmestelle_id=5
Mohamed Cherif Bouchelaghem
@cherifGsoul
Nov 07 2017 22:46
so your base is different
Julian
@pYr0x
Nov 07 2017 22:46
i dont understand
Mohamed Cherif Bouchelaghem
@cherifGsoul
Nov 07 2017 22:47
before thinking about js
Julian
@pYr0x
Nov 07 2017 22:48
/todos will create a ajax request to localhost/todos if the current location is e.g. localhost/foobar it will go to localhost/todos
Mohamed Cherif Bouchelaghem
@cherifGsoul
Nov 07 2017 22:49
it does this if in .htaccess you put RewriteBase /
or try todos/{id} instead of /todos/{id}
the app folder is todos?
Julian
@pYr0x
Nov 07 2017 22:51
RewriteBase does not solve the problem.. i changed it to the folder but same problem
Mohamed Cherif Bouchelaghem
@cherifGsoul
Nov 07 2017 22:52
just todos/{id} without the first / should work on localhost
the issue is the client can not know that localhost is the base url
Julian
@pYr0x
Nov 07 2017 22:53
but with a starting / it will go to the base url
same as an anchor tag
href="/todo" will go to localhost/todo
Mohamed Cherif Bouchelaghem
@cherifGsoul
Nov 07 2017 22:54
the baseurl like this will be the current url
Mohamed Cherif Bouchelaghem
@cherifGsoul
Nov 07 2017 22:59
@pYr0x to avoid surprises between dev and prod I use virtual hosts for examples: myapp.dev and for apis myapp.dev/api with url rewriting configured
Julian
@pYr0x
Nov 07 2017 23:00
but the same config worked on a other project
i think i will delete my node modules
Mohamed Cherif Bouchelaghem
@cherifGsoul
Nov 07 2017 23:00
ok
Julian
@pYr0x
Nov 07 2017 23:01
and take the versions from the last project
and see if there is a bug in can connect
Julian
@pYr0x
Nov 07 2017 23:06
nope
the same
Julian
@pYr0x
Nov 07 2017 23:17
is it EntnahmestelleDetail.get() or EntnahmestelleDetail.getData()
?
there is a big bug in can-connect
.getList() make a request to http://localhost/api/probe
but .get() doesnt
Chasen Le Hara
@chasenlehara
Nov 07 2017 23:25
Hey Julian, I’m catching up on the convo
.get() should work for getting a single instance: https://canjs.com/doc/can-connect/constructor/constructor.get.html
I wonder if the url object should have something like "GET /todos/{wwentnahmestelle_id}"
…then you could write EntnahmestelleDetail.connection.get({wwentnahmestelle_id: 1234})
Julian
@pYr0x
Nov 07 2017 23:29
but whats happen if i use url: '/api/probe',
see that test repo
Chasen Le Hara
@chasenlehara
Nov 07 2017 23:33
Ah ok, so then I think .get({probe_id: 1234})should result in /api/probe/1234
…but I don’t know if it’s smart enough to figure out that probe_id should be used for the URL
I would expect it to with that algebra, but I’m not sure
Does it work if you expand it to the object syntax?
{
  getListData: "GET /api/probe",
  getData: "GET /api/probe/{probe_id}",
  createData: "POST /api/probe",
  updateData: "PUT /api/probe/{id}",
  destroyData: "DELETE /api/probe/{probe_id}"
}
Julian
@pYr0x
Nov 07 2017 23:38
let me try
yep that will work
i will use the url object in the future
:)
thank you very much
Chasen Le Hara
@chasenlehara
Nov 07 2017 23:46
👍 Glad we figured it out
It still feels like what you had should’ve worked, because the id was specified in the algebra